Home
Forum
Software
Mouser's Software
NANY: New Apps for the New Year
Friends of DC
Forum Coding Snacks
Editorials
Daily Blog
Monthly Newsletter
Mini Reviews
Favorite Websites
Archives
Articles
Historical Archives
Testimonials: What Folks Say About Us
Licensing
Get a License Key
Commercial Licensing
Help
Search
FAQs
DonationCoder Sitemap
Live Chat (Discord)
Contact Us
About Us
Donate
Home
Forum
Software
Mouser's Software
NANY: New Apps for the New Year
Friends of DC
Forum Coding Snacks
Editorials
Daily Blog
Monthly Newsletter
Mini Reviews
Favorite Websites
Archives
Articles
Historical Archives
Testimonials: What Folks Say About Us
Licensing
Get a License Key
Commercial Licensing
Help
Search
FAQs
DonationCoder Sitemap
Live Chat (Discord)
Contact Us
About Us
Donate
This topic
This board
Entire forum
Website and forum (google)
Member search
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
6 Months
Forever
Login with username, password and session length
Wednesday December 11, 2024, 4:40 pm
Proudly celebrating 15+ years online.
Donate now
to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
Forum Home
Search
Login
Register
Recent Topics
Go To..
Recently updated topics
Recent posts (compact)
Recent posts (full text)
DonationCoder.com Forum
»
Main Area and Open Discussion
»
General Software Discussion
»
replace files in batch
« previous
next »
New Topic
Print
Pages: [
1
] •
bottom
Author
Topic: replace files in batch (Read 2928 times)
kalos
Member
Joined in 2006
Posts:
1,824
replace files in batch
«
on:
October 22, 2012, 05:07 PM »
hello!
I have a directory, where there are many files with the same filename, inside various subdirectories
I want to replace each of these files, with a specific file I have
how can I do this at once? any solution?
thanks!
skwire
Global Moderator
Joined in 2005
Posts:
5,287
Re: replace files in batch
«
Reply #1 on:
October 22, 2012, 08:18 PM »
This is easy to do but there is one caveat. Do you want to replace the "contents" of these filenames with your specific file or do you want to replace the entire file with a new file. For example:
Assume the files that need replacing are named
File.txt
. Assume the file you want to use as a replacement is named
NewFile.txt
.
1) Did you want to replace the
contents
of
File.txt
with the
contents
of
NewFile.txt
(thus leaving the original
File.txt
name in place)?
2) Or, did you want to completely replace
File.txt
with
NewFile.txt
.
Of course, this scenario is moot if you're looking to replace
File.txt
with a completely different file that is also named
File.txt
.
kalos
Member
Joined in 2006
Posts:
1,824
Re: replace files in batch
«
Reply #2 on:
October 23, 2012, 07:46 AM »
the 2)
I want to replace the whole files File.txt with NewFile.txt
but the source file (the file that will replace the others) is named File.txt as well
skwire
Global Moderator
Joined in 2005
Posts:
5,287
Re: replace files in batch
«
Reply #3 on:
October 23, 2012, 08:38 AM »
Here's an AuotHotkey snippet that should do it (adjust variables as necessary). However, run it on a test folder structure first.
Code: Autohotkey
[Select]
myDir
:=
"c:\tmp6"
; Will be recursed.
myFileName
:=
"File.txt"
; Filename to look for. Name only, no path.
myReplacementFile
:=
"c:\File.txt"
; Full path to replacement file.
Loop
,
% myDir
.
"\*.*"
,
0
,
1
{
If
(
A_LoopFileName
=
myFileName
)
{
FileCopy
,
% myReplacementFile
,
%
A_LoopFileFullPath
,
1
}
}
kalos
Member
Joined in 2006
Posts:
1,824
Re: replace files in batch
«
Reply #4 on:
October 23, 2012, 08:41 AM »
it does the job, thanks!
New Topic
Print
Pages: [
1
] •
top
« previous
next »
DonationCoder.com Forum
»
Main Area and Open Discussion
»
General Software Discussion
»
replace files in batch