First of all, it's fun to see there is another thread started this same month asking nearly the same question - i did used G to search but not the forum itself.. In any case, the RENAME command is what i first tried by checking at the docs but that didn't work properly, specifically i've used:
GO &NAME&
SELECT *.{$exts}
RENAME PATTERN ".*\.{$exts}" TO "&NAME&.\1" REGEXP
COPY MOVE *.{$exts}
GO Back
DELETE "&PATH&" FORCE QUIET ALL
Problem is when selecting multiple folders, it just work on the first one - i guess cause of the Go command required for selecting files for the RENAME command, unless im missing something. So, i was hoping this could be achived from the source path with a single COPY procedure. :-/
However, the other day i just wanted to add "avi" and "mkv" to the list, and noticed it doesn't work if the filename (referenced as &NAME&) contains spaces. I checked the rename takes place on such case, and the file(s) removed, so the problem here should be the COPY command somehow (due the use of the wildcard at the end of the string, i guess)
So... i thought i could just get rid of that whole .bat-based button and use a "native" one instead with the FILTER arg, and it'd work like a charm if it weren't due the file extension thing :-/
You need to add @nofilenamequoting to the button if you are adding the quotes yourself, otherwise you'll get two lots of quotes when things contain spaces.
Hi Leo, thanks to your tip i've just realized what the real problem is... the name is something like "Title [HDTV][2013]" so, those [] are conflicting with wildcards - is there some way to escape them?
@runmode hide
CD "&PATH&\"
paren.bat "&NAME&"
Copy MOVE "&PATH&\&NAMEE&\&NAMEE&*"
//DELETE "&PATH&\&NAME&" FORCE QUIET ALL
(Template: NAME/A,PATH/A,NAMEE/A)[/quote]
You may not need to escape anything but the last component of the path (I'm not sure, though). (On the other hand, if you need all parts of the path to be escaped, then the {s} part (PATH variable) would need it as well.)
There's also an extra \ or two in there since {s} will have a \ on the end. You might want to use {s|noterm} to prevent it and keep the slashes in the command itself for clarity.
By the way, you might want to make sure the delete line at the end is safe. I'm not sure exactly what this will be used on or where things are being moved to here, so it might not matter, but the example in the Buttons forum for moving things up one level has a discussion about why it may be better to use the DOS rmdir command to clean up folders after moving everything in them around. Using rmdir lets you avoid deleting directories which are not empty.
(In the "moving things up one level" case, you might have C:\A\A and move everything in C:\A up one level. You'll still have files in C:\A afterwards because the A directory got moved up one level.)
I just wrongly assumed everything had to be escaped, and since i knew the path didn't contain any special char i just did it that way to test. It quite makes sense now that you said it that just the last part should be escaped. In any case, i wanted to get rid of the .bat and finally i did it.
As for the purpose of the button, i download everything to some folders inside D:\ and from there i manually organize them, moving the files to some other places of the D:\ drive. The button is to move the files which matter, and deleting everything else. So, the folders aren't in fact empty after the button's action is executed, they end up with some other files i don't care about (such as .txt, .diz, or .url)