Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


jamesvdale01
2013-10-28T12:07:49Z
I have a directory with sub directories, and I want to copy a file from each of these subdirectories into a single new directory but WITHOUT the sub directory structure.

\\server\sub1\file1.txt to \\myserver\file1.txt
\\server\sub2\file2.txt\ to \\myserver\file2.txt.
.... etc.

So I would like to COPY \\server\ as the SOURCE, check the Include sub directories box, give it a file mask file*.txt and then have a destination of \\myserver\ with an option to NOT create the sub directory structure of sub1, sub2 etc.

I have LOTS of sub directories.
Sponsor
Forum information
bweston
2013-11-05T16:42:48Z
Originally Posted by: jamesvdale01 

I have a directory with sub directories, and I want to copy a file from each of these subdirectories into a single new directory but WITHOUT the sub directory structure.

\\server\sub1\file1.txt to \\myserver\file1.txt
\\server\sub2\file2.txt\ to \\myserver\file2.txt.
.... etc.

So I would like to COPY \\server\ as the SOURCE, check the Include sub directories box, give it a file mask file*.txt and then have a destination of \\myserver\ with an option to NOT create the sub directory structure of sub1, sub2 etc.

I have LOTS of sub directories.



In the general case, that has a lot of potential for naming collision, which I suspect is related to why there isn't built-in support for this.

I recommend using powershell. An off-the-cuff outline for accomplishing that (hopefully I'm getting the syntax right):


$list = Get-ChildItem \\server\ -Recurse -File
# I recommend a check here for filename collisions
$list | copy-item -Destination \\myserver\

# If you know for sure you don't need collision checking, you can one-line it:
gci \\server\ -Recurse -File | cp -Destination \\myserver\


...Disclaimer: I'm running Powershell 3 locally and I don't remember when the -File switch was added. The syntax for "just files, don't list directories" might have been more verbose in 2.0.

You can pass the -WhatIf flag (at least in 3.0) to the copy action to make sure it's going to do what you want before you do it. I should have done that when I tested it...I left off the -File switch the first time, and...yeah, don't do that.
Support
2014-02-13T22:12:00Z
This feature has been added in 7.1.3.

http://www.visualcron.co....aspx?g=posts&t=3805 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top