Renaming recursively files with alphabetical order

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
crazyroot
Posts: 13
Joined: 14 Dec 2016 19:44

Re: Renaming recursively files with alphabetical order

#16 Post by crazyroot » 02 Jan 2017 07:23

Happy 2017 to all of you ;) !!
What a miraculous gift for the new year :wink: , thank you so much Phil !

This solves everything, really wonderful. And I learned so much thanx to you, Phil and Antonio. This forum is very competent, I'm impressed.

This time it's very highly leveled for me ;), I didn't understand the whole script. If you can, could you please give me some explanations :

- about the syntax of :separate module, how it works and how can I use it ? especially, what does it mean : if :SUB==only ?

Code: Select all

 rem use call with copies for testing 
 rem call :seperate
if :SUB==only * You want test with seperate Files * & @(
:seperate
rd /s /q "%folder%" 2>nul >nul
md "%folder%"
robocopy /create /mir D:\music "%folder%" /njh /fp /ndl /nfl /njs
exit /b
)


- about the Substlist (set Substlist= %Q% %R%) : how it works and is it possible to see the list in a file in %tempfolder% ?

It's however easy to run and it does the work (it renames perfectly), so the questions above are only to understand better and use it fully ;) Thank you again Phil, I think you'll have a beer ;)

pieh-ejdsch
Posts: 240
Joined: 04 Mar 2014 11:14
Location: germany

Re: Renaming recursively files with alphabetical order

#17 Post by pieh-ejdsch » 02 Jan 2017 13:29

Code: Select all

call :seperate
-------------
if is around test data from the original data in eien seperaten working folder / test Folder to copy.
The function is summarised after the condition into a block.
Because the function still settings stands Needed this before the end of her Settings

It looks unusual a little bit, but I use this for two reasons:
1. to the testing of Scripts with echo ON
2. the function is in the Script directly under it
3. at the end of the function is nobody - goto:Label_behind_function inevitably
4. the block with the Subroutine is jumped over after the implementation because of the condition
5. with will test only the line IF Especially indicated
6... thereby point I as far script has come

the command IF compares both expressions and becomes only if the condition is true execute the sequence command.

The command IF still has a specific feature:
If the first printout to be compared begins with a colon, everything becomes between to the expressions including those not indicated.
The CMD parser reads in the complete IF - command line, around this with echo ON before to indicate the instruction execution nocheinmal.
Oh, I see with the Asterisk - does not become as a command parse him can exist, because no file may include.

Thereby becomes with echo ON in the batch from

Code: Select all

if :String1==String2 * small explanation * & @(command...)
to

Code: Select all

if * small explanation * &
Theoretically every subroutine is able with it in script direct after call
and all closing parenthesis (level 0) are attached.

Code: Select all

call :subST_LW Q "%%folder%%"
-----------------------
The Script automatically assigns a disk drive letter, with it with this virtual disk drive it can be gone on working.
Of the 2nd par offices is transmitted in double percent signs, because in call is reduced to one percent sign.
the argument (variable) thereby becomes only in the subroutine Expanded.

Code: Select all

set Substlist=%Q% %R%
----------------------
A variable the virtual disk drive is created with the letters, with it all created allocations again are lifted

The variables Q and R are created with the virtual disk drive letters and are used in the rest of the Script

list in the files in %tempfolder%
-------------------------------
The files can delete by the command before him are indicated:

Code: Select all

explorer "%tempfolder%"
pause
rd /S /Q "%tempfolder%"
Thanks, the beer was very good

Phil

crazyroot
Posts: 13
Joined: 14 Dec 2016 19:44

Re: Renaming recursively files with alphabetical order

#18 Post by crazyroot » 02 Jan 2017 15:27

OK, thanx for the explanations, if I well understood there is no file containing a list like before but instead, there's an entire copie of folders and files in %tempfolder% which is scanned in :process subroutine ?

A real beer when I see you ;)

Post Reply