#11 2022-12-10 18:45

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: ReNamer command line: "add files in this folder and it's subfolders"

jogiwer wrote:
jogiwer wrote:

... Actually I am not sure what will be made out of the cmd call:

cmd /c "cd "C:\path with spaces\" && renamerscript.bat"

Will the quotation arround the path work or not? Windows is so much different than all the unix shells.

Took a look at "help cmd". In this case the outer quotation marks will be ignored completly:

cmd /c cd "C:\path with spaces\" && renamerscript.bat

Thus the path parameter will get its "!


Right.
The outer quotes are only to keep all commands together. Here for the cmd.exe interpreter.
And each interpreter (mostly) will eat the outer quotes and process the embedded commands.






 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#12 2022-12-10 18:50

jogiwer
Member
From: Germany
Registered: 2022-11-05
Posts: 66

Re: ReNamer command line: "add files in this folder and it's subfolders"

Stefan wrote:
jogiwer wrote:

What all of this can not handle is snazzys wish to only in include files down to second level...



With VBS script I have counted the number of "\" in the path to stop at a given number of "\"s.
For PowerShell there is a script somewhere with key word "deep"

For batch me think you can could use the FOR command?:
FOR /L %%parameter IN (start,step,end) DO command
FOR /L %%parameter IN (0,1,2) DO ( your commands here ) 

Mmmh - you read my post just halfway ... I also gave the solution with:

for /D %%S in (%folder%\*) do %rn% /enqueue %%~fS

The /L version of the FOR command will only generate numbers ...

Offline

#13 2022-12-10 18:59

jogiwer
Member
From: Germany
Registered: 2022-11-05
Posts: 66

Re: ReNamer command line: "add files in this folder and it's subfolders"

Stefan wrote:

Right.
The outer quotes are only to keep all commands together. Here for the cmd.exe interpreter.
And each interpreter (mostly) will eat the outer quotes and process the embedded commands. 

That is not right in this case I believe.

Normally I would join you and would say quotes have to come in pairs. If they were kept we would have got to quoted strings:
"cd "
and
" && renamerscript.bat"

But cmd parses it differently as you could read in "help cmd" - mine is only german so have a look here.

There it states:

microsoft wrote:

If you specify /c or /k, cmd processes, the remainder of string, and the quotation marks are preserved only if all of the following conditions are met:

You don't also use /s.

You use exactly one set of quotation marks.

You don't use any special characters within the quotation marks (for example: & < > ( ) @ ^ | ).

You use one or more white-space characters within the quotation marks.

The string within quotation marks is the name of an executable file.

If the previous conditions aren't met, string is processed by examining the first character to verify whether it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.

So here a special handling will come in charge ...

Last edited by jogiwer (2022-12-10 19:03)

Offline

#14 2022-12-10 20:28

snazzy
Member
Registered: 2022-12-09
Posts: 3

Re: ReNamer command line: "add files in this folder and it's subfolders"

wow, many thanks to both of you. It will take a while for me to digest this, but I will have a dive and report back (may take some time). Thanks so much for the loyal responses!! snazz

Last edited by snazzy (2022-12-10 20:35)

Offline

#15 2022-12-10 22:47

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: ReNamer command line: "add files in this folder and it's subfolders"

The /L version of the FOR command will only generate numbers ...

Really?, try:
FOR /L %p IN (1,1,2) DO @echo No. %p &@echo.  & DIR /w &@echo ------------



"cd "
and
" && renamerscript.bat"

This should be then:
"cd "
and
&&
and
"renamerscript.bat"


The above command:
cmd /c "cd "C:\path with spaces\" && renamerscript.bat"
becomes
cd "C:\path with spaces\" && renamerscript.bat
for the interpreter to parse. The outer quotes are removed by the interpreter.



 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#16 2022-12-11 00:53

jogiwer
Member
From: Germany
Registered: 2022-11-05
Posts: 66

Re: ReNamer command line: "add files in this folder and it's subfolders"

Stefan wrote:
The /L version of the FOR command will only generate numbers ...

Really?, try:
FOR /L %p IN (1,1,2) DO @echo No. %p &@echo.  & DIR /w &@echo ------------
 

Yes really! The directory listing is generated by the "DIR /w" in your command chain. There are no pathnames put into %p.

This would only print the numbers with some text:

FOR /L %p IN (1,1,2) DO @echo No. %p
Stefan wrote:
"cd "
and
" && renamerscript.bat"

This should be then:
"cd "
and
&&
and
"renamerscript.bat"

I just tried some unix-like parsing and pasted the strings between an opening " and the following (closing) " - and that was done only hypthetical ...
On a shell the backslashes would have escaped on " at least and parameters could get also longer as long there is no space outside the quotes. Just to explain:

bash-4.4$ command=( a b c "hello world" )
bash-4.4$ for i in "${!command[@]}";do echo "    $i: <${command[$i]}>";done
    0: <a>
    1: <b>
    2: <c>
    3: <hello world>
bash-4.4$ command=( cmd /c "cd "C:/path with spaces/" && renamerscript.bat" )
bash-4.4$ for i in "${!command[@]}";do echo "    $i: <${command[$i]}>";done
    0: <cmd>
    1: </c>
    2: <cd C:/path>
    3: <with>
    4: <spaces/ && renamerscript.bat>

Stefan wrote:

The above command:
cmd /c "cd "C:\path with spaces\" && renamerscript.bat"
becomes
cd "C:\path with spaces\" && renamerscript.bat
for the interpreter to parse. The outer quotes are removed by the interpreter. 

This is exactly what microsoft is saying in their quoted description/documentation:

microsoft wrote:

If the previous conditions aren't met, string is processed by examining the first character to verify whether it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.

Offline

Board footer

Powered by FluxBB