I created a super basic robocopy
robocopy C:\temp F:\temp /xo
However I want to copy files from C:\temp that only contain the number "852" in them. These are logs for a on side program we use however there is 1000s of files but only need to capture the ones that have 852 in them. Then I want to run this via task scheduler once a week. Anyone know if this is possible?
Related
Our programming archives contain tons of PLC programs (thousands of files)
Was recreating our backup structure, and wanted to filter through some of the junk. Made a batch file to delete all folders containing BAK with extension .acd, all files with .SEM, and .WRK, as these three are extra files that are created with opening the program, and are not needed. Some have gotten copied to the archives and duplicated many times.
I tested it on a copy of the folders, and wanted to run it routinely before the structure gets duplicated to other backup systems to prevent the backups from becoming cluttered again.
Here's the script I used:
del /q /s "Y:\Bays\*BAK*.acd"
del /q /s "Y:\Bays\*.Sem*"
del /q /s "Y:\Bays\*.Wrk*"
It deleted thousands of files, but as I watched I noticed three that did not make sense to me.
See the middle two deleted files:
"With Email" file:
These three were deleted, yet don't contain BAK in their names. I don't want to routinely run this if it will risk removing any copies of programs that aren't the automatically generated ones. Just hoping someone may be able to explain why these three were the only ones out of the thousands of deleted files to not follow the rule.
As you know, batch cannot delete files from directories with spaces between words. That's actually a bug that cannot be fixed, and wasn't built-in. So, I think that it's because of the unknown file extension, it happened the same to me. To make it known to your device, type regedit at the search bar, go to HKEY_CLASSES_ROOT, add a new key, and name it as the extension. Close regedit and try again.
Volume has property to enable generate short file names (8.3).
This property affects the execution of commands (del, for).
I have volume D where 8dot3 name creation is disabled
There is a file with name 1.abcd in folder.
Command for %i in (*.abc) do echo %i not find any files
I have volume C where 8dot3 name creation is enabled
There is a file with the same name 1.abcd in folder.
Command for %i in (*.abc) do echo %i find this file
Maybe if you use long file names then you need to disable generating short file names. You can do it with fsutil.
I have two remote servers. One that I am currently connected to and one that I am trying to copy a lot of files to (10.10.0.13)
I have a series of files I need to copy within various directories of the format:
/opt/DR/output/1/a/csva1file.csv
/opt/DR/output/1/a/csva2file.csv
/opt/DR/output/1/b/csvb1file.csv
/opt/DR/output/1/b/csvb2file.csv
/opt/DR/output/1/b/csvb3file.csv
/opt/DR/output/1/b/csvb4file.csv
/opt/DR/output/1/c/csvc1file.csv
...
/opt/DR/output/30/a/csva1file.csv
And this continues for output/1 to output/40 folders. All the folders inside are identical and all the filenames inside will all contain similar strings, just with slight differences depending on the folder they are in.
I want to copy all the files that contain "a1" from any directory to a folder in a remote server:
root#10.10.0.13:/data/landing/a/a1/
Similarly, I want to do this for all b1, c1, c2 etc. files and copy them to their respective places on the remote server.
I cannot seem to find a way to do this that doesn't involve writing multiple lines of code.
I have tried
cd /opt/DR/output/1/a/
scp -r -v *a1* root#10.10.0.13:/data/landing/a/a1/
which works but I want to copy **ALL* the a1 csv files rather than having to do them one by one.
I have looked into globbing but don't think it can be used for my case. I have also looked at using paramiko/glob for python but I couldn't get that to work either.
Ideally, I would like to do this with a bash shell script, but a python script would also work.
Hope this makes sense. Any help would be greatly appreciated. I can copy via SFTP or SCP.
I have a custom script I use for backing up my hard drive to a temporary external drive. It's a simply a number of robocopy lines (without /PURGE). I've having trouble with the windows documents folder. If I have a command: "robocopy C:\users\me\documents D:\backups\somerandomdirectoryname ..", every time it's done, Windows thinks that directory is a Documents directory and even renames "somerandomdirectoryname" to "Documents". It changes the icon, and then I can not actually eject the USB drive because Windows will not let it go. What is causing Windows to do this to me? Is there something I have to exclude to make it "just a normal directory" on my external device?
Found a cure to this, use the option:
/XA:SH
which stops copying system and hidden files - which are how the special attributes of the Document directory appear to be copied. Worked for me, I only wanted the data files.
Working on archiving a boatload of project folders (wasn't getting done for a while before I stumbled in). Active and inactive projects are in the same directory, and it's way past time to put the inactive projects in a retirement ho-drive...archival drive.
robocopy \\vm\projects\##-#### \\vm\archive\##-#### /e /sec /xo /xa:hs /r:1 /w:1 /v /fp /tee /log+:dir\logDATE /blahblahblah
TL;AGR - How am I going to replace the ##-####'s with a list I've generated (without typing each of the 800-ish names out)?
This is what the previous admin left, and it's fine for a monthly project archive (finishing maybe 30 projects a month and manually entering their names). I'm now reporting 1100 projects in this directory, 800 of which don't appear on my active project list.
It's important to note that these projects are not named logically, there's no "active" tag (outside of our management software), and that their appearance in any sort is random.
I've exported an .xls and cleaned it up, leaving only a list of inactive projects. Now I'm stuck and I'd rather not waste too much time with manual entry, although I'm game if there isn't an easier solution...
Thanks!
-Ian
Figured this out shortly after posting:
With the project numbers in a single column, I wrote a concatenate command around the project number, pulled the first two characters to name a folder in which each prefix got sorted, then ctrl+dragged the formula down the list. A simple copy/paste into a notepad document, save as batch, and run sorted the whole mess out. Thanks for the suggestions!
-Ian
I have a batch that integrates an xml file time to time but could happens daily. After it integrates it puts in a folder like /archives/YYMMDD(current day). The problem is if the same file is integrated twice. So I need a script what verifys the file (with diff command its possible but risky to make a bottleneck) but the problem is I can't find to resolve how to make to give the second files location.
P.S. I can't install on the server anything.
Thanks in advance.