Search This Blog

Showing posts with label robocopy. Show all posts
Showing posts with label robocopy. Show all posts

Friday, April 10, 2020

Testing This Awesomeness Out Right Now

HOLY CRAP! THIS WILL BE AWESOME, if it works!

On Recursively delete empty directories in Windows, which was asked 10 years, 7 months ago, this solution was posted:

You can also use ROBOCOPY. It is very simple and can also be used to delete empty folders inside large hierarchy.

ROBOCOPY folder1 folder1 /S /MOVE

Here both source and destination are folder1, as you only need to delete empty folders, instead of moving other files to different folder. /S option is to skip copying(moving, in the above case) empty folders. It is also faster as the files are moved inside the same drive.

I'm currently testing out this idea now in a test directory structure and, thus far, it's working great. I created two files in Notepad and put each file in a separate folder. This means that when the above command is complete, if I have one folder with a single sub-folder under, each folder with a total of two files, I can add the above command to every DOS batch file I have ever created that uses "md" (make a directory) commands!

Monday, October 29, 2018

ROBOCOPY Returns to My Focus

I started out the day running this DOS Batch file that uses the more efficient "ROBOCOPY" command instead of the tested / verified / awesome "XCOPY" command. However, I quickly realized that the commands below were insufficient because each ROBOCOPY command was set up to copy the entire "S:\Disaster Recovery Planning" folder into each of the sub-folders within the c:\rh\drm folder structure, which is not what I want to do. What I want is:

to copy the CSV files within S:\Disaster Recovery Planning to the c:\rh\drm\csv folder
to copy the DOC* files within S:\Disaster Recovery Planning to the c:\rh\drm\DOC folder
repeating that logic for each of the file types I've specified in the commands below.

This is my original code:

cd\
c:
cd c:\rh\drm
rd /s /q c:\rh\drm\csv
rd /s /q c:\rh\drm\doc
rd /s /q c:\rh\drm\jpg
rd /s /q c:\rh\drm\png
rd /s /q c:\rh\drm\pdf
rd /s /q c:\rh\drm\ppt
rd /s /q c:\rh\drm\txt
rd /s /q c:\rh\drm\vsd
rd /s /q c:\rh\drm\xls
rd /s /q c:\rh\drm\zip
pause
md c:\rh\drm\csv
md c:\rh\drm\doc
md c:\rh\drm\jpg
md c:\rh\drm\png
md c:\rh\drm\pdf
md c:\rh\drm\ppt
md c:\rh\drm\txt
md c:\rh\drm\vsd
md c:\rh\drm\xls
md c:\rh\drm\zip
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\csv *.csv /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\doc *.doc* /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\jpg *.jpg /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\png *.png /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\pdf *.pdf /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\ppt *.ppt* /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\txt *.txt /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\vsd *.vsd* /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\xls *.xls* /E
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\zip *.zip /E
pause

I am very happy I had inserted "pause" commands so that I could check the progress in the destination folder because I quickly realized my syntax was wrong. Thanks to https://stackoverflow.com/questions/472692/how-to-copy-a-directory-structure-but-only-include-certain-files-using-windows, I know what I would need to do and, actually, I've improved upon the process. My original idea was to use a separate command to copy each file type to a folder for that file type, but now I realize, I can use a single command to copy the files to a single directory structure, use SearchMyFiles.exe to look for all the files in that single folder structure - instead of specifying each sub-folder - select all the files, cut, and paste into the root folder. Then I still use a second DOS Batch file to move each file type to a folder for that file type.

cd\
c:
cd c:\rh\drm
rd /s /q c:\rh\drm\csv
rd /s /q c:\rh\drm\doc
rd /s /q c:\rh\drm\jpg
rd /s /q c:\rh\drm\msg
rd /s /q c:\rh\drm\png
rd /s /q c:\rh\drm\pdf
rd /s /q c:\rh\drm\ppt
rd /s /q c:\rh\drm\txt
rd /s /q c:\rh\drm\vsd
rd /s /q c:\rh\drm\xls
rd /s /q c:\rh\drm\zip
pause
md c:\rh\drm\csv
md c:\rh\drm\doc
md c:\rh\drm\jpg
md c:\rh\drm\msg
md c:\rh\drm\png
md c:\rh\drm\pdf
md c:\rh\drm\ppt
md c:\rh\drm\txt
md c:\rh\drm\vsd
md c:\rh\drm\xls
md c:\rh\drm\zip
pause
robocopy "S:\Disaster Recovery Planning" c:\rh\drm\baggage *.csv *.doc* *.jpg *.msg *.png *.pdf *.ppt* *.txt *.vsd* *.xls *.zip /E

One command instead of 10 is always a cool thing!
It makes the requirements for using SearchMyFiles.exe easier as well. Here's the before:



See? Much more slick!

Monday, April 11, 2016

Explanation

Regarding this cryptic post, the RoboCopy commands to create a backup on my 1 TB EHD (F) completed and the stats for the jobs are on that post. After those commands finished, I began another set of XCOPY commands to further separate the files I had been able to find on my working EHDs:
copy all JPG files that start with 0-9 from f: to a directory on the MyCloud I: drive
copy all JPG files that start with A-Z from f: to a directory on the MyCloud I: drive
to end up with
I:\0\0* files
I:\1\1* files
I:\a\a* files 
... you get the idea. Because I used the XCOPY command with the /s parameter, I then have to use Search My Files to find all the files and cut them from the sub-folder to the root directory. Of course, this creates a lot of duplicate files that have to be separated into at least 5 categories:
  1. My pictures
  2. Karen's pictures
  3. Megan's pictures
  4. Alex's pictures
  5. Not one of the above
I expect this process to take a bit of time - as in hours - to complete. Even if I could finish a letter or number in one hour, that would be 35 hours and would take about a month, which is a very generous ballpark estimate. It is, of course, mid-April and our "busy" season. Talk has already turned to our soon to be chaotic schedule. On a very non-in-depth level, here's what the next month looks like:
  • West High production of "Mary Poppins" on 4/16
  • Mark, Susie, and the boys coming to our house on 4/22
  • Alex going to Beartooth at Gabe's Oasis on 4/23
  • Pulling the camper from storage in Zhwingle to Elkader for camping season on 4/30
  • Megan moving home from UNI, Jesse Manibussen concert at church, Karen's XX birthday, Mother's Day on May 6
  • Bring Me the Horizon concert on May 12 in Des Moines
  • Alex's Europe trip auditions in Des Moines, Matthew's wedding, and Alex's prom on May 14

Finding the time to sort hundreds of files? Going to be interesting...

Sunday, April 10, 2016

Stats

-------------------------------------------------------------------------- 
F:\_drive_J>robocopy j: f:\_drive_j /s
                Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :      1066      1065         1         0         0         0
   Files :     55305     55305         0         0         0         0
   Bytes : 176.954 g 176.954 g         0         0         0         0
   Times :  31:04:53  30:49:04                       0:00:00   0:15:49


   Speed :             1712606 Bytes/sec.
   Speed :              97.996 MegaBytes/min.

   Ended : Sat Apr 09 14:49:48 2016

------------------------------------------------------------------------------


F:\_drive_k>robocopy k: f:\_drive_k /s

                Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :     88115     88114         1         0         0         0
   Files :    440029    440029         0         0         0         0
   Bytes : 278.013 g 278.013 g         0         0         0         0
   Times :  66:18:39  60:30:35                       0:00:30   5:47:33


   Speed :             1370368 Bytes/sec.
   Speed :              78.413 MegaBytes/min.

   Ended : Sun Apr 10 15:38:04 2016

------------------------------------------------------------------------------

M:\>robocopy m: f:\_drive_M /s

                Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :     10145     10144         1         0         0         0
   Files :     78169     78169         0         0         0         0
   Bytes :  39.303 g  39.303 g         0         0         0         0
   Times :  21:55:03  20:30:54                       0:00:00   1:24:09


   Speed :              571421 Bytes/sec.
   Speed :              32.696 MegaBytes/min.

   Ended : Sat Apr 09 19:44:30 2016

------------------------------------------------------------------------------

F:\>robocopy x: f:\_drive_x /s

                Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :      4899      4898         1         0         0         0
   Files :     67060     67060         0         0         0         0
   Bytes : 174.820 g 174.820 g         0         0         0         0
   Times :  44:19:29  43:20:48                       0:00:30   0:58:10


   Speed :             1202902 Bytes/sec.
   Speed :              68.830 MegaBytes/min.

   Ended : Sat Apr 09 17:41:59 2016

Friday, April 8, 2016

A Special Report Part Two

Editor's Note: This special report initially began as an entry in the table on the page I use on this blog to track the Reconversion project. However, due to the desire to write an extended essay, I moved the text to a blog post. The Reconversion page is located here.

I'll be honest now and say the fact that I had been moving files from the MyCloud drive to this new drive instead of copying files was idiotic. I should have copied the files to the new drive, done my organization work, and then made a backup. The problem, though, is that the MyCloud drive is a 4 TB drive and the new drive is a 4 TB drive. I would have needed to still remove all of the files on the MyCloud in order to wipe it clean so I could delete all the Shares on it, which was the whole point of moving the files off of it.

I only mention this because it was not smart to be doing all of this work I had been doing without a backup. That's the bottomline - I should know better. After all, I work with files and computers daily and cannot count the number of times I needed a backup of the work I just finished. I used to be really good about making backups. At Quintrex, every Friday, I would run a DOS batch file in order to copy all of my documentation files that I had on my C:\ drive to BSS's PC (because his PC had a CD burner while mine only had a CD player). Then I would burn a backup, which required multiple CDs to do.

The fact that I may have lost the music files that were created by ripping CDs is not a terribly big deal. Yes, it means re-doing hours and hours of work but, as I think I've mentioned, my plan has always been to finish the conversion and then audit it by reconverting.

The fact that I had moved a lot of Alex's files and a lot of Megan's files and a lot of Karen's files to the 4 TB EHD without a backup.... that's a terribly big deal. I'll just be brutally honest and say that when Karen and Alex found out about what I had done and that family pictures could be lost, they were furious. I deserved their fury.

In the meantime, I located a lot of JPGs that had not been moved to the 4 TB EHD. In fact, I found a directory of duplicate files - hundreds of files with (2) in the file name. I am in the process of running 7 Robocopy commands to not only consolidate the files I found to a single EHD, but to also make a backup of those files.

My prayers are to update the reconversion page on 4/15/2016 with the good news that Chad was successful in not only recovering the 4 TB EHD, but also in recovering the other two dead EHDs.

Monday, March 7, 2016

RoboCopy, Powershell, and good ol' DOS really rock my world. In a quest to condense files in multiple folders into a single folder with a command, I found this article. Now a DOS window is happily processing a command similar to this one:
robocopy C:\ C:\OutputFolder *.pdf /S /R:1 /W:1 /NDL /XJD /XD OutputFolder /L

Monday, September 1, 2014

Rain Rain Rain

Nothing beats spending time with my wife and her family in a camper as it rains outside. 12 of us. Lou, Susie, mark, Karen and Megan playing cards, Jonathan and Danny and Tyler on handheld devices, Alex and Jean finding a game on television, barb and I sitting on the couch.
My imdb.com app is getting a workout.
On another note, talking with Mark R and Steve R was a highlight of this weekend. Another was going to Guardians of the Galaxy at the Elkader theater yesterday at 330 with Megan. A third highlight was not going to bed and then waking up with a terrible headache that 2 Aleve hasn't taken away.
It's not even 1 PM and I am already thinking about Vanessa's issue with Confluence. When she tries to export to PDF, there's a table that gets cut off. I think there is a way to make it work but I don't know what it is at the moment. I'm hoping to get back home fairly early so I can try to figure it out.
I'm also anxious to get home so I can see if the RoboCopy job that I left running when we left the house on Saturday morning has been completed. If it's done, I think I will be able to resume the task of consolidating the files on the MyCloud drive to some sort of structure that makes sense. I created such a mess. Each of the two times I had an external hard drive fail resulted in copying duplicates to more than one of the partitions. My goal is to reduce the number of duplicates and reduce the space being used.
It's unclear whether the plans outlined above will come to fruition.

Wednesday, August 27, 2014

Mentioned Thousands

I have been working rather feverishly on the CD to MP3 conversion. I am in what I would call the final stretch. I have, roughly, 500 more CDs to go. I have also been consolidating the music and other files on the MyCloud drive. Bluntly, I created a mess and have so many duplicates that it is a terrible and time consuming mess. As I write this, I have 4 DOS windows open on the Toshiba laptop running RoboCopy from 4 different partitions on the MyCloud to an external hard drive. In the meantime, I have already copied some of the files from those directories into my 'master' music folder and the result is that when I ran my DOS batch file a little while ago, I had 93199 File(s). Lucky for me, I have a freeware called Search My Files and I can look for all files with (2) in the file name and delete them. It's not a big deal to also look for all files with @ in the file name and delete them. Yet, it's also kind of fun to say "I have 93,199 files in my music collection."