Go Back  PPRuNe Forums > Misc. Forums > Computer/Internet Issues & Troubleshooting
Reload this Page >

a fast way to replace 1000+ files?

Wikiposts
Search
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

a fast way to replace 1000+ files?

Thread Tools
 
Search this Thread
 
Old 23rd Jan 2009, 09:41
  #1 (permalink)  
Thread Starter
 
Join Date: Aug 2002
Location: Strategic hamlet
Posts: 115
Likes: 0
Received 0 Likes on 0 Posts
Question a fast way to replace 1000+ files?

Does anyone know of a command or software that can copy and replace multiple files? I have about 1600 different bitmap files in a folder that needs to be replaced by copies of a single white bitmap, and it will take some major effort to copy and rename every single file manually.
Massey1Bravo is offline  
Old 23rd Jan 2009, 12:01
  #2 (permalink)  
Uneasy Pleistocene Leftover
 
Join Date: Feb 2003
Location: Gone, but not forgotten apparently?! All forums marked "Private"...
Posts: 320
Likes: 0
Received 0 Likes on 0 Posts
Not sure about the utility of
...replaced by copies of a single white bitmap...
but I use ThumbsPlus whenever I need to alter multiple images in the same way. It has a great "batch-process" function for multiple files, allowing easy conversion to/from most image formats; renaming - keeping the old file name, adding a prefix or suffix, numbering options - lots of ; changing image resolution and resizing; image enhancements, cropping etc.

Pretty sure that it'll do what you want. But there's probably a cheaper way to do it in MS-DOS...?!
airship is offline  
Old 23rd Jan 2009, 23:53
  #3 (permalink)  
 
Join Date: Mar 2008
Location: Germany
Posts: 9
Likes: 0
Received 0 Likes on 0 Posts
2nd attempt, 1st one crashed the thread and got deleted.

Assuming you are using Windows and have Excel or the OO counterpart, there is a away using DOS commands.

It's a bit annoying but there's nothing else I could think of except googling for a tool that does the same with less legwork.

1) Create a .txt file in your target folder (the one with the 1000+ files) and rename it to something like step1.bat. Windows will warn you about the extension, but it's okay.
2) Right-click on the text file and edit it to contain this command: dir /B >filelist.txt
3) Save the file and close it.
4) Double-click step1.bat to run it. You'll have a file list called filelist.txt in no time.
5) Open filelist.txt in Excel. Excel will ask a couple of questions but the answers should be obvious. You now have the list of target names on column A
6) Move the target names to column C, fill column A with xcopy and column B with the name of your source file, including extension. Fill column D with /Y unless you want to confirm each overwrite. Each line in your Excel file should look something like this: Xcopy sourcename.bmp targetname.bmp /Y
7) Save this as step2.txt in your target folder (make sure file format is still .txt and not XLS) and then rename to step2.bat using the Explorer or something like that
8) Copy the source file to the target folder
9) Read this warning: if all was done right and all goes according to plan running step2.bat will overwrite your original bmps. There is no way to recover them once the batch file was run. Better create a backup first.
10) Run step2.bat, check all was copied ok and clean away the temporary files

That's it, sounds more complicated than it is, really. Feel free to PM me for clarification.

However, if someone knows a better way, I am eager to hear it as I use the above process a lot.
DUS SLF is offline  
Old 24th Jan 2009, 01:36
  #4 (permalink)  
Thread Starter
 
Join Date: Aug 2002
Location: Strategic hamlet
Posts: 115
Likes: 0
Received 0 Likes on 0 Posts
It worked! Many thanks DUS SLF!

I thought about the Xcopy command but I didn't know about the Excel trick.
Massey1Bravo is offline  
Old 6th Feb 2009, 19:27
  #5 (permalink)  
 
Join Date: Apr 2008
Location: UK
Posts: 27
Received 0 Likes on 0 Posts
Late as ever.
For those without Excel (a brilliant piece of lateral thinking BTW).

First ensure that the new file blank.bmp has been copied to the existing oldpix data folder & then create the following batch file (my_name.bat) in a convenient location (e.g. root), modifying folder/file names and paths as necessary.

MD c:\newpix
CD c:\oldpix
MOVE blank.bmp c:\newpix
DIR /B > c:\newpix\filelist.txt
CD c:\newpix
FOR /f %%n IN (filelist.txt) DO COPY c:\newpix\blank.bmp c:\newpix\%%n
I think this will work but no promises as I only used a set of 30 files to test it. Note, the FOR DO statement is all one line.
In rerum natura is offline  
Old 6th Feb 2009, 21:57
  #6 (permalink)  
Spoon PPRuNerist & Mad Inistrator
 
Join Date: Sep 2003
Location: Twickenham, home of rugby
Posts: 7,390
Received 247 Likes on 165 Posts
A small addendum to the pipe command:

If you wish to pipe (>) the output of a command to an existing file just use >> to the filename.

SD
Saab Dastard is offline  
Old 10th Feb 2009, 04:32
  #7 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
rerum - I think you'll need a "shift" command

Batch files - Command line parameters

Mac the Knife is offline  
Old 10th Feb 2009, 06:18
  #8 (permalink)  
Upto The Buffers
 
Join Date: Apr 2006
Location: Leeds/Bradford
Age: 48
Posts: 1,112
Likes: 0
Received 0 Likes on 0 Posts
This is a prime example of why downloading bash for Windows and the Unix Utils (all free) is very useful. 1 line, no hassle.

for i in `ls coldpix` ; do cp cnewpic.bmp coldpix\$i ; done

Shunter is offline  
Old 10th Feb 2009, 06:20
  #9 (permalink)  
Upto The Buffers
 
Join Date: Apr 2006
Location: Leeds/Bradford
Age: 48
Posts: 1,112
Likes: 0
Received 0 Likes on 0 Posts
This is a prime example of why downloading bash for Windows and the Unix Utils (all free) is very useful. 1 line, no hassle.

Unfortunately I can't paste it, due to the idiotic smiley crap which messes with everything in sight.
Shunter is offline  
Old 10th Feb 2009, 10:24
  #10 (permalink)  
 
Join Date: Feb 2000
Location: asia
Posts: 542
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by Shunter
This is a prime example of why downloading bash for Windows and the Unix Utils (all free) is very useful. 1 line, no hassle.

for i in `ls c:\oldpix` ; do cp c:\newpic.bmp c:\oldpix\$i ; done

:ok:
If you repost and tick the option box "disable smilies" all the crap you complain about will disappear and we can learn. I'll do it for you this time
stickyb is offline  
Old 10th Feb 2009, 18:31
  #11 (permalink)  
 
Join Date: Apr 2008
Location: UK
Posts: 27
Received 0 Likes on 0 Posts
Mac

The last time I wrote batch files in anger I had to type copy con: my_file.ext at the DOS prompt and terminate the text with ^Z and a quaint thing called a carriage return (anything was better than edlin). But my %%n is a variable and not a parameter so I don't think the shift command is syntactically relevant (chemo brain...I even lost my specs in the snow...so I am happy to stand corrected). SD? As I said, I did test the 'program' after I scribbled it down and before posting. Very quick and dirty, no errorlevel, if exist, if not exist checks and no clean up afterwards. But non-destructive, at least.

Of course, the source and destination paths and file names could be passed as parameters (%1..%9) from the command line in which case the shift command might become pertinent (that's something for you to do, Homer, find that out). But all the meat is in the last line (which is essentially the Bash command suggested by Shunter), which was sufficient to answer the OP's question. Thanks for the page linked to, though, which I have saved to disk and will study later; Microsoft's help page for XP batch file commands is very limited in its scope. Looks like you're expected to part with even more money for books which used to be supplied with the OS (GW Basic reference, command line reference, batch file reference). For a really hard core batch file (whose workings I don't for a moment pretend to understand) have a look at this:
Stupid Coding Tricks: A Batch of Pi - The Daily WTF

FOR /f %n IN (filelist.txt) DO COPY /Y blank.bmp %n
can be entered at the command prompt in source=target directory but is destructive.
IRN

Last edited by In rerum natura; 26th Mar 2009 at 01:22. Reason: The fidgets
In rerum natura is offline  
Old 25th Mar 2009, 21:07
  #12 (permalink)  
 
Join Date: Mar 2009
Location: City
Posts: 1
Likes: 0
Received 0 Likes on 0 Posts
Script to copy over 1600 bitmap files

Massey1Bravo has the following requirement:

Does anyone know of a command or software that can copy and replace multiple files? I have about 1600 different bitmap files in a folder that needs to be replaced by copies of a single white bitmap, and it will take some major effort to copy and rename every single file manually.
Hi Massey1Bravo:

I will write a script for you.

I will assume the following.

1. You have over 1600 bitmap files in the folder "C:/Bitmaps" and, possibly, its subfolders. Their file extension is .bmp.
2. You want to copy over each of these files a single white bitmap stored at "C:/MasterBitmap.bmp".
Here is my script. It is written in biterscripting. (Download biterscripting free, if you don't have it. The installation instructions are at http://www.biterscripting.com/install.html . It is excellent for doing a lot of things like this.)

(I will admit that I am following one of the sample scripts that came with biterscripting - so this is not all my original work.)

Code:
 
 
# Collect a list of files that are to be copied over.
car str filelist ; find -r -n "*.bmp" "C:/Bitmaps" > $filelist
 
while ($filelist <> "")
do
    # Get the next file.
    var str file ; lex "1" $filelist > $file
    # The full path name of the file is in $file. Delete, then copy.
    system del ("\""+$file+"\"")
    system copy "C:/MasterBitmap.bmp" ("\""+$file+"\"")
done

Save the script in some file (say, C:/X.txt), start biterscripting and run the command

Code:
script "C:/X.txt"
That's it.

Let me know if this works for you.

Randi
RandiR is offline  
Old 26th Mar 2009, 10:42
  #13 (permalink)  
 
Join Date: Jul 2006
Location: Up yer nose, again.
Age: 67
Posts: 1,233
Received 15 Likes on 12 Posts
I have about 1600 different bitmap files in a folder that needs to be replaced by copies of a single white bitmap
Something you need to hide?

Peter Fanelli is offline  

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.