Therefore, you do not need to add all known folder names to any if conditions in your bat/ cmd file.ġ) Use a for /f loop to list all folders with the layout target delimited by - and using the 1-2-3 tokens, and %%~a-%%~b-%%~c has become the same for your folder name layout SDF543-bbb-X0001 for /f tokens^=1-3delims^=^- %%a in ('dir /on/b/a:d *-*-*')do If not "!_dir!" = "" move /y "%%~fa-%%~b-%%~c" "!_dir!"įor your fifty or more directories, with a predictable name layout, this bat/cmd code can automate the task, so that no editing is necessary. This command can be used to rename files or directories on all Windows OS editions i.e Windows 2000, XP, Vista and Windows off & setlocal enabledelayedexpansionįor /f "tokens=1-3 delims=-" %%a in ('dir /b /a:d "*-*-*"')do >nul ( ![]() Both Ren and Rename refer to the same command. We can also use ren (the short form of rename) for rename operations. ![]() If you try to do that you will get the error – “The syntax of the command is incorrect.” That is why it does not accept full path for the target file name. This command just renames the existing file/folder and does not create a new file. Note that, with rename command, we can’t move the files to another drive or directory. We can use Rename command to rename directories too. In Renaming files from command line we saw how to rename files using Rename command.
0 Comments
Leave a Reply. |