1.

Solve : Picture Scanner And Copier?

Answer»

I am writing this little batch that will scan the C:\Documents and Settings\%USERNAME% directory and sub directories for any given file type, I am currently searching for .jpgs. It then makes a log of all the files it found and makes a temp directory in c:/picrip where I would like it to copy all the files I found; HOWEVER I am stuck with moving the files. Here is my code so far. Can anyone HELP?

Code: [Select]: Pic Rip v0.1.4
: Scans current directory and
: sub directories for images.
: Makes log of images and transfers
: images to FTP.
: ~AaoN~ Monday, Spetember 3rd, 2007

@echo off

:Gives program title.

title Pic Rip v0.1.4

: Moves to C:\

CD c:\

: Makes picrip directory

md picrip

: Moves to c:\Documents and Settings\%USERNAME%

cd c:\Documents and Settings\%USERNAME%

: Preliminary Search, Removes Attributes

attrib /s *.jpg -a -h -r -s

: Does the serach and makes log

attrib /s *.jpg > picrip.log

attrib /s *.jpg | copy c:\picrip

: Moves log to c:\picrip

copy picrip.log c:\picrip

echo All done. Have a good day! >> picrip.log

: Deletes c:\Documents and Settings\%USERNAME%\picrip.log

cd c:\Documents and Settings\%USERNAME%

del picrip.logWhat OS are you using? How do you want to handle duplicate files? And why are you changing the attributes of the files? I based this code off what I think you want to do assuming Windows XP, but have excluded the commands that I didn't see the purpose of, or added the functionality into existing commands.

You probably want something like
Code: [Select]@echo off
title Pic Rip v0.1.4
if not exist C:\picrip md C:\picrip
if exist C:\picrip\picrip.log del C:\picrip\picrip.log
for /f %%a in ('dir "C:\Documents and Settings\%username%" /a /s /b) do (
echo %%a >>C:\picrip\picrip.log
xcopy "%%a" C:\picrip /h
)
echo All done. Have a good day! >>C:\picrip\picrip.log
Since you are copying files from all subdirectories of C:\Documents and Settings\%username% (which will include IE temporary internet files), you MAY encounter duplicate file names. In the case of the above script, I BELIEVE it will only keep the first copy.

The dir /a /s /b will list all files including hidden and system files, which I think is why you used attrib on the files? The xcopy with /h will copy hidden and system files. The for /f will allow you do do what I think you were building the log file for.Quote

@echo off
title Pic Rip v0.1.4
if not exist C:\picrip md C:\picrip
if exist C:\picrip\picrip.log del C:\picrip\picrip.log
for /f %%a in ('dir "C:\Documents and Settings\%username%" /a /s /b') do (
echo %%a >>C:\picrip\picrip.log
xcopy "%%a" C:\picrip /h
)
echo All done. Have a good day! >>C:\picrip\picrip.log

I think you missed a " ' " , apostrophe.Quote from: DeltaSlaya on September 03, 2007, 11:30:08 PM
I think you missed a " ' " , apostrophe.

Ah, yes. Good catch.


Discussion

No Comment Found