Windows 10: How to find files in sub-directories and copy to a specific root directory automatically?

Discus and support How to find files in sub-directories and copy to a specific root directory automatically? in Windows 10 Software and Apps to solve the problem; Hello all and Happy New Year in advance,I have a root folder containing over a hundred folders, that have at least one level sub-folders themselves.... Discussion in 'Windows 10 Software and Apps' started by CricriYR, Dec 30, 2024.

  1. CricriYR Win User

    How to find files in sub-directories and copy to a specific root directory automatically?


    Hello all and Happy New Year in advance,I have a root folder containing over a hundred folders, that have at least one level sub-folders themselves. Most of the folders contain a file of FILE type no extension somewhere in their structure, generally in a sub-folder.I want to scan all the whole directory structure, and copy all the files of type FILE to the root directory.How to I automate this in Windows, hopefully using Microsoft tools rather than third-party tools, although I will use the latter if easier to set-up as I will need to repeat this kind of operation many times in future.Thank

    :)
     
    CricriYR, Dec 30, 2024
    #1

  2. Script can copy file directory in one spot but not the other

    It's having trouble copying any of the files in the sub directories of frank. All the files directly under frank are properly backed up and the originals are properly edited.

    The script runs using a foreach, looking for any file that ends with a specific extension, in the directory specified. It uses File::find to locate each file. The script first copies the file and adds "orig" to the extension name, for example the file is .origpy instead of .py. The original file is changed from read only to full write permissions. Then it is opened for reading, all is read into memory except the comments. The file is closed. The file is opened for writing. Everything from the file in memory is written to file. The file is closed, and changed back to read only.

    This works great in Linux. I tried it in XP, its fine as well. just something about the directory structure on this server that wont let it work for the sub directories in frank.
     
    Hybrid_theory, Dec 30, 2024
    #2
  3. Script can copy file directory in one spot but not the other

    Haha yeah its fred. sorry its 8am and my mind isnt fully functional yet. There is an error along side the one my script posts: No such file or directory at script line 20.(which is the copy line). I pointed the script to one of the sub directories exactly, still wouldnt copy. I created a new sub dir, and copied some of the files from the main directory into the new directory, those wouldnt copy either.

    script:
    Code: #!/usr/bin/perl -w use strict; use warnings; use File::Find; use File::Copy; my $directory="..\\..\\doc\\xsd"; find (\&subr, $directory); sub subr { foreach ($File::Find::name=~/(.*)\.xsd$/) { my $filetobecopied = $File::Find::name; my $newfile = $1 . ".origxsd"; copy($filetobecopied, $newfile) or die "$File::Find::name cannot be copied $!"; chmod 0777, $File::Find::name; open (FILE, "<", $File::Find::name) or die "Cannot open file $!"; print $File::Find::name. "\n"; local $/; my $file=<FILE>; $f=~s/<!--[\w\W^]*?-->//gi; close FILE; open (OUT, ">", $File::Find::name) or die "Cannot write to file $!"; print OUT $f; close OUT; chmod 0444, $File::Find::name; } }[/quote] thanks kreij
     
    Hybrid_theory, Dec 30, 2024
    #3
  4. Kreij Win User

    How to find files in sub-directories and copy to a specific root directory automatically?

    Script can copy file directory in one spot but not the other

    What exactly is the issue when copying files from sub-directories of "Fred"?
    Are you a domain or enterprise admin?
     
    Kreij, Dec 30, 2024
    #4
Thema:

How to find files in sub-directories and copy to a specific root directory automatically?

Loading...
  1. How to find files in sub-directories and copy to a specific root directory automatically? - Similar Threads - find files sub

  2. How to find files in sub-directories and copy to a specific root directory automatically?

    in Windows 10 Gaming
    How to find files in sub-directories and copy to a specific root directory automatically?: Hello all and Happy New Year in advance,I have a root folder containing over a hundred folders, that have at least one level sub-folders themselves. Most of the folders contain a file of FILE type no extension somewhere in their structure, generally in a sub-folder.I want to...
  3. How to ind files in subdirectories and copy to a specific root directory automatically?

    in Windows 10 Gaming
    How to ind files in subdirectories and copy to a specific root directory automatically?: Hello all and Happy New Year in advance,I have a root folder containing over a hundred folders, that have at least one level sub-folders themselves. Most of the folders contain a file of FILE type no extension somewhere in their structure, generally in a sub-folder.I want to...
  4. How to ind files in subdirectories and copy to a specific root directory automatically?

    in Windows 10 Software and Apps
    How to ind files in subdirectories and copy to a specific root directory automatically?: Hello all and Happy New Year in advance,I have a root folder containing over a hundred folders, that have at least one level sub-folders themselves. Most of the folders contain a file of FILE type no extension somewhere in their structure, generally in a sub-folder.I want to...
  5. Copying files into WindowsApps directory

    in Windows 10 Gaming
    Copying files into WindowsApps directory: Hello, I want to copy some files into game directory in WindowsApps, but firstly I have access denied, so I have changed permission for every user. Now I have got access to that directory, but I cannot copy any files into it. Everytime it says that I don't have right...
  6. Copying files into WindowsApps directory

    in Windows 10 Network and Sharing
    Copying files into WindowsApps directory: Hello, I want to copy some files into game directory in WindowsApps, but firstly I have access denied, so I have changed permission for every user. Now I have got access to that directory, but I cannot copy any files into it. Everytime it says that I don't have right...
  7. Copying files into WindowsApps directory

    in Windows 10 Software and Apps
    Copying files into WindowsApps directory: Hello, I want to copy some files into game directory in WindowsApps, but firstly I have access denied, so I have changed permission for every user. Now I have got access to that directory, but I cannot copy any files into it. Everytime it says that I don't have right...
  8. Copying files into WindowsApps directory

    in Windows 10 Network and Sharing
    Copying files into WindowsApps directory: Hello, I want to copy some files into game directory in WindowsApps, but firstly I have access denied, so I have changed permission for every user. Now I have got access to that directory, but I cannot copy any files into it. Everytime it says that I don't have right...
  9. How to start a command in a sub-directory ?

    in Windows 10 Support
    How to start a command in a sub-directory ?: Hi, when i have a sub-directory "bin", which has a cake.exe, and i type "bin/cake" or "./bin/cake" or "/bin"cake" it cant't finde the cake.exe. I'm getting an error message for example: "'bin' is not recognized as an internal or external command" How is the right syntax ?...
  10. Quixxxx.tmp directories on root

    in Windows 10 Support
    Quixxxx.tmp directories on root: I have all these directories starting with Qui...tmp on one of my laptops. about 20-30 of them, all empty. I get nothing via google. Anyone ever seen this? 67218