A list of useful CMD Commands that you can use on windows for file management and such. If you ever get stuck just do "help [Command]" without the quotations.
Note that if your paths have spaces in them you need to encapsulate it with ONLY " ". For example if you have a path like New Folder 1/New Folder 2, you will need to input it as "New Folder 1/New Folder 2", or else CMD will treat the spaces as separate commands.
Command | Usage |
---|---|
del [file_path] | Delete a file |
copy [file_path] [copy to folder path] | Copy a file to some folder |
del [file_path] | Delete a file |
move [file_path] [move to folder path] | move a file to some folder |
ren [old_filename] [new_filename] | move a file to some folder |
mkdir [folder_name] | Make a new dir called "folder_name" in the current directory |
cd [folder_path] | Change working directory to folder_path |
Command | Usage |
---|---|
tree | Shows a tree of the folder and its subdirectories |
dir | Shows the files and folders |
dir /b /a-d | List all of the files in the current directory |
Note that the %[letter] can be any letter. It just represents a variable in the CMD.
Command | Usage |
---|---|
FOR /L %I in (0,1,10) DO mkdir "Folder %I" | Make a bunch of incrementing folders called "Folder #" in the current directory. /L allows you to do ranges(start, step, end) |
FOR /L %I in (0,1,10) DO echo "FILE %I" > "File %I.txt" | Create an incrementing list of text files and Write FILE # into each file. |
FOR /D %d in (*) DO mkdir "%d/New Folder" | Make "New Folder" in all folders of current directory. You can change the (*) to some other format to select only specific files. For example (iot-*) folders that start with "iot-". You need the /D to loop through the folders |
FOR %a in (*.pdf) DO ren "%a" "0%a" | Add a leading 0 to all of the files in the folder with .pdf extension |
FOR %a in (*.txt) DO ren "%~a" "%~na version 1%~xa" | Add "version 1" right before .txt |
FOR /D %a in (*) DO FOR %b in ("%a/*.csv") DO copy "%a\%b" "..\New folder" | Copy all .csvs from child directories to "New Folder" in the parent directory |