Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Picture Scanner And Copier  (Read 4288 times)

0 Members and 1 Guest are viewing this topic.

aaon

  • Guest
Picture Scanner And Copier
« on: September 03, 2007, 07:39:41 AM »
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.log

GuruGary



    Adviser
    Re: Picture Scanner And Copier
    « Reply #1 on: September 03, 2007, 11:20:44 PM »
    What 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.

    DeltaSlaya



      Apprentice
    • Google
      Re: Picture Scanner And Copier
      « Reply #2 on: September 03, 2007, 11:30:08 PM »
      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.
      System specs:
      Intel Core 2 Duo E6600 (up to 3.3 stock V and air)
      ASUS Striker Extreme
      XFX 8600GT XXX Edition
      2x 1gB Corsair XMS2 DDR2-800
      Seagate Barracuda 320gB SATA
      Raidmax Ninja 918 (520W ATXV2.0 PSU)
      -

      GuruGary



        Adviser
        Re: Picture Scanner And Copier
        « Reply #3 on: September 04, 2007, 10:32:17 PM »
        I think you missed a  " ' "  , apostrophe.

        Ah, yes.  Good catch.