Windows 7/Continuing

Advertisement


Question
QUESTION: That worked better, but it did not find all the files. It only found the first.  For PN 22624800, there are two photos: 22624800.JPG and 22624800_ALTERNATE1.JPG.

Keep going, you are so close. You are amazing!
Francyn

ANSWER: hi there

mm, strange, can you double check the folders you have given me for spelling etc, they need to exactly what on you drive:

gm-photos-alternate
gm-primary-2010
gm-primary-2011
gm-primary-2012
gm-primary-2011

There are also 2 x gm-primary-2011  is this right?( should be a 2013?)

i think i might need to add another loop

regards


scott

---------- FOLLOW-UP ----------

QUESTION: gm-photos-alternate
gm-primary-2010
gm-primary-2011
gm-primary-2012

There is also acdelco-battery-photos but I don't think anything will be in there, but you can never tell...

The scrip did create two sub folders in my ACDPhotoRequest folder.  One called 01-26-2012 had one file (22624800.JPG) and the other 02-02-12 had 22624800.JPG.  If it is any easier, it doesn't need to go into a subfolder, it can go right into ACDPhotoRequest.

The partno.txt had four files in it.
22624800
22627378
22627379
22632575
Two of these had no photos.

ANSWER: hi again

ok then delete C:\Users\Francyn\Desktop\ACDPhotoRequest


and wipe the script.bat again and copy and paste the below and run it



@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

md C:\Users\Francyn\Desktop\ACDPhotoRequest
SET "DEST_DIR=C:\Users\Francyn\Desktop\ACDPhotoRequest"
SET "SEARCH_DIR=E:\gm-primary-2012"

FOR /F "tokens=*" %%a IN ('type %~dp0partno.txt') DO (
FOR /R "%SEARCH_DIR%" %%f IN (*%%a*) DO (
    SET "SRC=%%~dpf"
    SET DEST=!SRC:%SEARCH_DIR%=%DEST_DIR%!
    xcopy /S /I "%%~f" "!DEST!"
)
)


SETLOCAL ENABLEDELAYEDEXPANSION

SET "DEST_DIR=C:\Users\Francyn\Desktop\ACDPhotoRequest"
SET "SEARCH_DIR=E:\gm-photos-alternate"

FOR /F "tokens=*" %%a IN ('type %~dp0partno.txt') DO (
FOR /R "%SEARCH_DIR%" %%f IN (*%%a*) DO (
    SET "SRC=%%~dpf"
    SET DEST=!SRC:%SEARCH_DIR%=%DEST_DIR%!
    xcopy /S /I "%%~f" "!DEST!"
)
)


SETLOCAL ENABLEDELAYEDEXPANSION

SET "DEST_DIR=C:\Users\Francyn\Desktop\ACDPhotoRequest"
SET "SEARCH_DIR=E:\gm-primary-2010"

FOR /F "tokens=*" %%a IN ('type %~dp0partno.txt') DO (
FOR /R "%SEARCH_DIR%" %%f IN (*%%a*) DO (
    SET "SRC=%%~dpf"
    SET DEST=!SRC:%SEARCH_DIR%=%DEST_DIR%!
    xcopy /S /I "%%~f" "!DEST!"
)
)

SETLOCAL ENABLEDELAYEDEXPANSION

SET "DEST_DIR=C:\Users\Francyn\Desktop\ACDPhotoRequest"
SET "SEARCH_DIR=E:\gm-primary-2011"

FOR /F "tokens=*" %%a IN ('type %~dp0partno.txt') DO (
FOR /R "%SEARCH_DIR%" %%f IN (*%%a*) DO (
    SET "SRC=%%~dpf"
    SET DEST=!SRC:%SEARCH_DIR%=%DEST_DIR%!
    xcopy /S /I "%%~f" "!DEST!"
)
)

regards

scott


---------- FOLLOW-UP ----------

QUESTION: We are getting them all but it's a little odd.


I ran it with 4 part numbers.  Let's use 24577078 to explain.
There are three images with 24577078 as part of their part number
24577078_ALTERNATE1.JPG was saved in ACDPhotoRequest folder directly
24577078_Primary (2).JPG was saved in a subfolder called "04-12-2012"
24577078_PRIMARY.JPG was saved in a subfolder called "07-14-2011"

I think I figured it out.  I looked where the original file was located and there are subfolders within the 5 folders. These are titled by date. So what is happening, the script is looking for the file, finds it within a sub folder and copies the subfolder and the single file to the new directory.  I can live with that. All I need to do then is move the .jpgs from the subfolder into the main directory. Easy with a .jpg search.

I am going to run a few more before sending this to you.  BRB

It really works. I can live with the subfolders. It only takes a moment to move them over.

You are amazing. I will leave great feedback!

Answer
Hi there

Ha ha, i was just about about to ask you if there were sub folders!  i wrote the script with just the ones you mentioned, i didn't think there were sub folders!  I made a mock up on my PC and it worked fine for me, so i was like wtf

It always going to be tough trying to do dos scripts when your not actually at the PC, but i agree its better you just push them across to the main directories

hopefully this will make life a little easier and you should be able to mess about with the script if you want to make changes, just google some of the things in it and it will become clear after a while.


regards


scott

Windows 7

All Answers


Answers by Expert:


Ask Experts

Volunteer


scott bartholomew

Expertise

General trouble shooting Hardware issues Networking issues I am not a software developer,but I can do some basic scripting in DOS and BASH.

Experience

Worked in IT for over 10 years and currently provide software and hardware support for a very large network of computers, including servers.

Education/Credentials
MCSA CCNA MCP x2 MCTS BTEC

©2016 About.com. All rights reserved.