Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 07, 2016, 02:24:45 PM
  • Proudly celebrating 10 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.
  • donate

Author Topic: DONE: Copy one particular file into every folder in a subdirectory  (Read 6310 times)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 315
    • View Profile
    • Donate to Member
Say we have a subdirectory -- c:\1 -- that contains 100 folders.  We have a file on our desktop -- file.txt -- that we want to go into every single one of those folders.

We could write a 100-line batch file to do this.

Is there an easier way?  A one-liner?

Thanks!




skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,666
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #1 on: April 05, 2013, 12:08:08 AM »
This is easily accomplished with a bit of AutoHotkey script.  Are you open to that?

nkormanik

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 315
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #2 on: April 05, 2013, 01:30:55 AM »
Sure I'm open to an AutoHotkey solution.  Anything to easily get the job done.  And that might be useful to others.  Who knows.

If, though, the best bet would be to simply write a long batch file, I'll stick with that.

Thanks.

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 585
    • View Profile
    • VDSFreak
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #3 on: April 05, 2013, 09:51:20 AM »
I know that skwire was going to make one in AutoHotkey, but this only took me a few to make. :-)

Easy to use, select the target folder and the source file. Press Go!

SubCopy Download

Ashampoo_Snap_2013.04.05_09h49m52s_001_SubCopy.pngDONE: Copy one particular file into every folder in a subdirectory

If you find any bug or issues, please let me know.
http://VDSFreak.com
Follow me on Tumblr.com to stay up to date on updates and new software!
« Last Edit: April 05, 2013, 09:58:03 AM by c.gingerich »

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,666
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #4 on: April 05, 2013, 11:55:37 AM »
Nicely done.  I sent my message last night and went to bed so it was nice to see this snack completed when I woke up.  =]  Nick, let us know if this will work for you and I'll mark this thread as done.

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 585
    • View Profile
    • VDSFreak
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #5 on: April 05, 2013, 11:57:48 AM »
Thanks!  :Thmbsup:
http://VDSFreak.com
Follow me on Tumblr.com to stay up to date on updates and new software!

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 2,927
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #6 on: April 05, 2013, 03:02:23 PM »
We could write a 100-line batch file to do this.
It could be made smaller than that with a "SWEEP" aka "GLOBAL" type utility that repeats a command in every directory matching a filespec.  Some can be found in the Fidonet batch programming echo's file depository, http://www.filegate.net/bfds/  These are old, though, and I don't know how well they'd work in current Windows consoles.

nkormanik

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 315
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #7 on: April 05, 2013, 05:13:40 PM »
You folks are amazing.  Another one DONE!

Thanks so much.

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 678
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #8 on: April 05, 2013, 06:32:44 PM »
Oh my, let's do it even easier.  Open a command prompt in the top folder and try:

           for /r %I in (.) do copy c:\folder\source.txt %I\target.txt

If you run it from a batch file you'd need to double the % marks.  Or if you don't want to navigate to the top folder for your command prompt, just enter its path after the /r and before the %I.

Edit: looking back at the original post, you could open a command prompt on your desktop (very easy with ContextConsole shell extension by the way) and enter the command as:

          for /r c:\1 %I in (.) do copy file.txt %I\file.txt
vi vi vi - editor of the beast
« Last Edit: April 05, 2013, 06:46:19 PM by x16wda »

nkormanik

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 315
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #9 on: April 06, 2013, 12:21:48 AM »
I've used c.gingerich's created program -- SubCopy -- a couple of times now, and it makes the task a piece of cake.

The great thing about these threads is that anyone searching the Internet trying to find a similar solution will probably be directed here.  Makes life a lot easier.

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 585
    • View Profile
    • VDSFreak
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #10 on: April 06, 2013, 06:53:13 AM »
I'm glad you like it and it does what you needed.  :D
http://VDSFreak.com
Follow me on Tumblr.com to stay up to date on updates and new software!

nkormanik

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 315
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #11 on: December 18, 2013, 08:17:34 PM »
Two questions:

1.  SubCopy seems not to work with copying "shortcuts" into the target folders.  Can Chris or anyone explain why it's hard to handle shortcuts?

2.  SubCopy presently doesn't allow copying "folders."  While I have a small use for doing that, does such a request seem a bit over-the-top?

===

Yesterday using SubCopy I repeatedly copied various files into 75 different sub-folders.  SubCopy saved a huge amount of time, energy, tedium.  Great little gem.


skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,666
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #12 on: December 18, 2013, 08:27:16 PM »
Can Chris or anyone explain why it's hard to handle shortcuts?

It's not a matter of difficulty.  The fact is, shortcuts are files, too (.LNK).  So, you can either move them like a normal file or you can extract information from them (target, working dir, etc.) and then use that information.  The problem is that, unless you write the code so that it extracts that information, it will be treated like a normal file.

nkormanik

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 315
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #13 on: December 18, 2013, 08:55:17 PM »
I find that indeed since the shortcut is a file..., if I RENAME the extension, yes, I can use SubCopy to copy to the various sub-folders.

Example:  Do.lnk ---> Do.lnkz

But without such renaming the extension, SubCopy won't copy the shortcut itself.

Trouble with the renaming of extension, one has to recursively go in and change the extension back to what it should be.

Recursively changing filename extension creates its own issue.  In present case..., 75 nested instances of Do.lnkz.


nkormanik

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 315
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #14 on: December 18, 2013, 09:44:29 PM »
Just in case I decide to recursively rename Do.lnkz back to Do.lnk...

...can you please remind me how to do that?

Do.lnkz ---> Do.lnk

In 75 sub-folders.


skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,666
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #15 on: December 18, 2013, 10:13:59 PM »
Just in case I decide to recursively rename Do.lnkz back to Do.lnk...
...can you please remind me how to do that?

Any of the myriad of file renamers out there will do the trick.  Find one you like...

nkormanik

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 315
    • View Profile
    • Donate to Member
Re: DONE: Copy one particular file into every folder in a subdirectory
« Reply #16 on: December 20, 2013, 01:54:47 AM »
Okay, Skwire, the renaming approach worked.

Chris, For some reason SubCopy doesn't allow directly inputting or even editing the field "Source file."  (Only option is Windows navigation and selecting.)  If user could do that, it may be possible to place the full path and name of the shortcut file.

Example:  c:\downloads\do.lnk

That would be easier than having to rename, copy to subfolders, and then recursively rename back again.

But, hey, at least the task can be accomplished.  I'm quite thankful for that.