1.

Solve : Read torrent File Names, Find corresponding Folder or File, Move DATA into a DIR?

Answer»

Is there any way to make a batch script to read the names of a bunch of torrent files in a directory ( C:\Documents and Settings\USER\APPLICATION Data\uTorrent )
then find the corresponding Folder or File with same name as the Torrent File in another directory ( E:\MEDIA-2 )
then move those Found  Folders & Files into a specific folder ( E:\Torrent-DATA )

Ex:
Batch file reads the name of a torrent file ( [HST] UFO Files - Real UFO's.torrent ) in Directory ( C:\Documents and Settings\USER\Application Data\uTorrent ) then searches for Either a Folder or a File in Directory ( E:\MEDIA-2 ) with the Corresponding Torrent File Name ( [HST] UFO Files - Real UFO's )
then if it finds something it moves the Entire Folder Contents or File to Directory ( E:\Torrent-DATA )

Is there anyway to something like this at all with a batch script..?? Code: [Select]SETLOCAL ENABLEDELAYEDEXPANSION
cd "C:\Documents and Settings\USER\Application Data\uTorrent"
for /f "tokens=* DELIMS=" %%A in ('dir /b *.torrent') do (
set add=%%A
set add=!add:~0,-8!
xcopy E:\MEDIA-2\!add! E:\Torrent-DATA
)
FBsweet thanx, so will this move or copy the Found Entire File & Folder + contents to E:\Torrent-DATA ..??sorry jumed the gun a little bit... it should now copy the file and contents to E:\Torrent-DATA

FBThanks
but I need it to MOVE the data to E:\Torrent-DATA though..!!!substitute xcopy with Robocopy /s /mov

FBwhat about this, will this work..??

SETLOCAL ENABLEDELAYEDEXPANSION
cd /d "C:\Documents and Settings\%username%\Application Data\uTorrent"
for /f "tokens=* delims=" %%A in ('dir /b *.torrent') do (
set add=%%A
set add=!add:~0,-8!
ATTRIB -S -H -R -A E:\MEDIA-2\!add!
xcopy E:\MEDIA-2\!add! E:\Torrent-DATA /E /F /I
del /F /Q E:\MEDIA-2\!add!
ECHO copied E:\MEDIA-2\!add!
)i dunno have you TRIED it? 

FBnot yet, i just threw it together, i wanted to make sure it looked legit to you 1st before i used it...??
what do you think.??what does this part of the code do exactly..??

set add=!add:~0,-8!the /f and echo won't do much cause the batch file will run too fast for you to read them if you want to see what file are being written you'll need to put Code: [Select]echo off at the beginning of your code and a Code: [Select] pause somewhere before the closing bracket.

I don't think xcopy copies attributes but you can leave in the attrib anyway incase i'm wrong. I can't see anything that is going to sop it from running but there's only one way to find that out.

the Code: [Select]set add=!add:~0,-8! removes the last 8 characters from the file name (.torrent) so that it becomes a directory name.

FBhey thanks for the help bro,
this seem works nice.

SETLOCAL ENABLEDELAYEDEXPANSION
cd /d "C:\Documents and Settings\%username%\Application Data\uTorrent"
for /f "tokens=* delims=" %%A in ('dir /b *.torrent') do (
set add=%%A
set add=!add:~0,-8!
ATTRIB -S -H -R -A "E:\MEDIA-2\!add!" /S /D
xcopy "E:\MEDIA-2\!add!" "E:\Torrent-DATA\!add!" /E /F /I && ECHO Copied "E:\MEDIA-2\!add!" >> E:\DATA.TXT
del /F /Q "E:\MEDIA-2\!add!"
rd /S /Q "E:\MEDIA-2\!add!"
)looks good, one point, if you use "rd /s" you don't need to use "del".

FBthe only hookup is when it detects a single file to copy it keeps asking me:
Does E:\Torrent-DATA\FILE-NAME.AVI specify a file name or directory name on the target
(F = file, D = directory)?
Is there anyway to automate that to auto detect and choose if its a File of Directory..?hmmm, not that i can think of but it is 2am here. unless there are any files with "." in them then it's ALWAYS going to be a filename.

FB



Discussion

No Comment Found