![]() :: %%~fa-%%~b-%%~c is the same to drive:\path\name_folder :: below to the value for the _dir variable: Set "_dir=%%~fa-%%~b-%%~c" :: if _dir variable was not removed, set the string Set "_dir=" ![]() Obs.: List your folders by name order: /onÄ¢) You can use if not to check if any values ââ(previous/last listed folder) are defined in the variable _dir, if the condition is true, the current folder will be moved to the last path to previous folder name defined in the _dir variable, and this will occur only if the path and part of name match the current variable %~fa if not "!_dir!" = "" move /y "%%~fa-%%~b-%%~c" "!_dir!"Ä£) The next command is something that does not make sense to me, that is, I have no idea how it works, even if theoretically it shouldn't work, but in fact it works.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
0 Comments
Leave a Reply. |