Jump to content

batch file and using the %D variable


Recommended Posts

hi, i have a question about the feature "run this program when a download finishes" which you can select per torrent. my question is with regards to the %D variable, is there a way of calling this from a batch file?, my reason is that i would like to write a batch file which does multiple processes, such as strip tag info, unzip, unrar etc when the torrent finishes, but if i use a batch for this then i cannot use the %D variable and thus cant tell the batch file where to find the downloaded files. is there a way of referencing this variable or is there another way around doing this using a batch file?.

any replies most appreciated!.

Link to comment
Share on other sites

hi spartakus, thanks for your reply, im a little confused by your example however, let me try and explain what im attempting to achieve:-

in utorrent i have the following command run when completed:-

rar x -df -r -o- %D\*.r* %D

however there are times when i also run this command on complete:-

tag --recursive --remove "%D\*.mp3"

so ideally i would like to point utorrent at a batch file which contains both commands, so the batch file would read

rar x -df -r -o- %D\*.r* %D

tag --recursive --remove "%D\*.mp3"

however the %D variable that utorrent identifies as the destination folder where the download has completed is only identified when the command runs from utorrent, if i use a batch file it doesnt know what %D is. i have also tried your suggestion of replacing %D with %1 in the batch file, but it still doesnt run against the downloaded files.

i have checked your app out and it does look useful but i want to be able to do more than just unrar, ideally i want to be able to run different commands depending on the type of file which i dont think your util does?.

Link to comment
Share on other sites

you will have to do this:

lets say the .bat file is called mybatfile.bat

from uT you will call it with

mybatfile.bat %D

the .bat file itself will look like this

rar x -df -r -o- %1\*.r* %1
tag --recursive --remove "%1\*.mp3"

in othe words, you use %D to call the file and %1 inside of it (as %D is the FIRST argument you pass to the .bat file, next argument will be %2 and so on)

Link to comment
Share on other sites

I must say I'm a little confused...


µTorrent will translate the line

C:\MyScript.cmd %D D:\Unrared


C:\Myscript.cmd D:\Downloads\Some.Cool.Show.S01E01.HDTV.XVID-GRP D:\Unrared

MyScript.cmd will see the parameters as

C:\MyScript.cmd %1 %2

%1 = D:\Downloads\Some.Cool.Show.S01E01.HDTV.XVID-GRP

%2 = D:\Unrared

Contents of MyScript.cmd:

"C:\Program Files\Winrar\unrar.exe" x -r %1\*.rar %2

...which in runtime would be:

"C:\Program Files\Winrar\unrar.exe" x -r D:\Downloads\Some.Cool.Show.S01E01.HDTV.XVID-GRP\*.rar D:\Unrared

Forgive me if I still don't see your point here...

Anyway, why would you remove the files you are seeding? That's would most likely lead to an error in the script or µTorrent complaining about missing files...

Btw, SCRU is strictly for unpacking. The source is available for modification to your liking.

Link to comment
Share on other sites

thanks for your replies spartakus and alpha-toxic, i now see what you mean, i was simply just running a batch file on completion in utorrent such as "utorrent.bat" with no variable used and referencing the %D in the batch file itself, i now understand what you mean by using the %1 in the batch file.

oh yeah btw spartakus the -r switch is recursive for the rar.exe, it doesnt remove the rar files, im assuming thats why you said "Anyway, why would you remove the files you are seeding? That's would most likely lead to an error in the script or µTorrent complaining about missing files..."

i did like the look of scru but i need a more flexible approach to run different commands on different file types, thus im going down the route of using a batch file, might make a nice feature addon for scru? :-).

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...