Giter VIP home page Giter VIP logo

lamename's Introduction

lamename.ps1

A lame powershell script to rename directories by prepending or appending text.

Options

-sourcedir      [path]      The directory to be modified
-prepend        [string]    Text to prepend to directory name, if switch not passed, nothing prepended
-append         [string]    Text to append to directory name, if switch not passed, nothing will be appended
-recurse        [switch]    Default Off. Recursively do through all subdirectories
-write          [switch]    Default Off. Actually make the changes, by default when you do not pass this switch, you just get a safe preview

Quick Example

Given a directory structure like the one provided in this folder

.\testdir
+---dir1
+---dir2
+---dir3withsub
    +---subdir1
        +---subsubdir1
PS C:\Users\collin\lamename> .\lamename.ps1 -sourcedir .\testdir -prepend 'CLIENTNAME-' -append '-AUDIT1' -recurse
C:\Users\collin\jmoney\testdir\dir1 ==> C:\Users\collin\jmoney\testdir\CLIENTNAME-dir1-AUDIT1
C:\Users\collin\jmoney\testdir\dir2 ==> C:\Users\collin\jmoney\testdir\CLIENTNAME-dir2-AUDIT1
C:\Users\collin\jmoney\testdir\dir3withsub ==> C:\Users\collin\jmoney\testdir\CLIENTNAME-dir3withsub-AUDIT1
C:\Users\collin\jmoney\testdir\dir3withsub\subdir1 ==> C:\Users\collin\jmoney\testdir\dir3withsub\CLIENTNAME-subdir1-AUDIT1
C:\Users\collin\jmoney\testdir\dir3withsub\subdir1\subsubdir1 ==> C:\Users\collin\jmoney\testdir\dir3withsub\subdir1\CLIENTNAME-subsubdir1-AUDIT1

Note the output format: sourcepath ==> destination_after_rename

Usage

  • Download the .zip of this and extract it somewhere
  • Open powershell and navigate to that directory (the goal is to run the script)

I had to run Set-ExecutionPolicy RemoteSigned to run scripts like this! I do not know a better way

  • Now you can start using the script
.\lamename.ps1 -sourcedir .\testdir -prepend 'BEGINNING-' -append '-AUDIT1' -recurse

Options are denoted with a leading - and their value immediately follows the option after a space

So:

.\lamename.ps1 -sourcedir .\testdir -prepend 'abc'

Sets the option prepend to abc

.\lamename.ps1 -sourcedir .\testdir -append 'xyz'

Sets the option prepend to abc and append to xyz

.\lamename.ps1 -sourcedir .\testdir -append 'xyz' -write

Sets the option prepend to abc and append to xyz and turns write on.

This is how you can compose commands in different ways for different cases.

Remember to actually make changes you must pass the -write, but always test first.

Notes

lamename's People

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.