move files in subdirs, not hidden files, to 1

April 20, 2011 at 12:21:17
Specs: Windows XP, 2ghz/2g
I need to move edited Picasa files from the sub folders that it creates on the fly via a batch file. Editing the jpg files leaves hidden folders and backup files that I do not want to copy. I tried this:

FOR /R "C:\My Pictures" %%a IN (.) DO MOVE "%%a\*.jpg" "C:\Temp"

But it found the 1500 hidden jpg files I didn't know about. So..........

How can I move the edited jpg files from unknown sub folder names without getting ones from hidden folders? I've looked through Picasa's options and didn't see anything that would help.

Thank you!

Steve


See More: move files in subdirs, not hidden files, to 1

Report •


#1
April 20, 2011 at 13:52:27
Try the following (untested) script

@echo off
pushd C:\My Pictures
move *.jpg C:\Temp
for /F "delims=" %%a in ('dir /B /AD-H /S') do move "%%a\*.jpg" C:\Temp
popd


Report •

#2
April 20, 2011 at 14:12:10
Thank you for your reply, a few questions for you:
1. I've never seen the pushd and popd commands, what do they do?
2. In line 3 the move command gets any jpg in the C:\My Pictures folder, correct?
3. Then line 4 gets the rest of the jpg files in sub-folders, but does it keep it from getting files from hidden folders?

Thanks again!
Steve


Report •

#3
April 20, 2011 at 14:30:56
1- pushd acts like cd storing the origin folder onto a stack where the popd restores it from. It is a way to retain your current directory while browsing folders (see pushd /? and popd /?).
2- absolutely correct.
3- the statement skips the hidden folders as directed by /AD-H switch. I worked out the script assuming move does not act upon hidden files and so the unwanted .jpg must be normal files stored in hidden directories accessed by your For /R.

My question: Did that do the job?


Report •

Related Solutions

#4
April 21, 2011 at 13:57:55
IVO, thank you for your informative reply, I will modify my batch file to reflect your suggestion, it will take me a few days to test it in production. Then I will update this ticket again. I've voted positive on your two posts already and will do so again once tested.

Thank you again!

Steve


Report •

#5
April 27, 2011 at 07:13:24
IVO, my users have not done any picture downloads to test it in a LIVE environment, but I am confident that your solution is the best. Is there a way to mark this question as solved and give you credit.
Thank you!

Steve


Report •

#6
April 28, 2011 at 04:00:23
Don't care further this thread, it is going to be buried by a lot of hotter questions.

If you need more support or anything goes wrong contact me by a private message.

Tnank you for your feedback.


Report •


Ask Question