How can I move files older than an x date (or number of days) from one directory to another but keeping the same directory tree? (Windows 7 or 10 DOS) - windows

I am trying to move all files from a directory (including subfolders) to another one using a DOS command but I want to keep the same directory tree...
I used the forfiles command but all old files end in the same directory, not organized by subfolders.

Related

How can I update modified date to current date in all files of a directory and its subdirectories? (Windows 10)

I need to update the modified date (and accessed date) of all files in a directory (Windows 10) and its subdirectories so that my company doesn't automatically delete them after a year of no modifications.
There might be thousands of files inside the directory so obviously, I can't do it manually.
It would be great if it could be done without using Python or other programming languages that need to be installed due to limited permissions in the system, directly with Windows CMD commands, but if it is necessary I might be able to get some temporary permissions.
As suggested in the comments, I've tried to use:
cd c:\yourFolder
copy c:\yourFolder,,+
But the solution doesn't update the files inside the subdirectories of my folder, so is there a way to do it for all the subdirectories in the tree?
Open the command prompt and navigate to your folder and execute the copy command with ,,+ params , example as follow.
cd c:\yourFolder
copy c:\yourFolder,,+
I have solved it by using the Windows PowerShell. After copying the complete directory, in PowerShell I did:
cd "C:\mydirectory"
dir -R | foreach { $_.LastWriteTime = [System.DateTime]::Now }
Which recursively "touched" all the files in the directory and subdirectories to make it look as if they had all been recently modified

Is there a way to copy files with a batch file to the folder that batch file is in?

So I am trying to make a batch file to sync an external hard drive.
My hard drive is not always connected to the same letter, so i cannot just make a batch file with xcopy F:\Folder1 G:\backupharddrive because G:\backupharddrivewould be variable
Is there a way to just copy to the folder the batch file is in?
Just use relative addressing, where . represents the current directory.
xcopy F:\Folder1 .
For future reference, you can also access the parent of the current folder (IOW, 1 level higher up in the directory tree) using ... This makes it handy to move up a level, or even over one. For instance, to copy files from C:\Temp\One to C:\Temp\Two, you can use
xcopy *.* ..\Two\
which means copy the files from this folder up one level and then over to the Two folder.
If you use dir from a command prompt, you'll see that in any level below the drive root you'll have items for . and .. in the list. (The root only has ., because it has no parent folder.

Sync files from Windows to Freebox(Linux) : prevent file recopy

I try to sync files from my Windows 7 computer to my Freebox (running Linux
I used rsync from unix like terminal (MobaXterm) and xcopy directly from windows bash as well.
In both case, whatever the set of option I used (inclusing operations on file attributes), I am unable to sync properly.
Problem is that each file is considered as new at each sync, and hence copied again, even if unmodified.
Problem comes from the file system. Windows is usually NTFS while Freebox (and some Linux) is FAT32 (in general not NTFS). File comparison based on dates concludes on differences between files. Using robocopy command on window with special option /fft solves the issue.
Example:
robocopy src dest /fft /e /purge
Will copy all files recursively from src to dest, removing on dest the non existing ones on src and handling correctly the files date attributes through different file systems, avoiding unecessary recopy.

Batch file to copy files from multiple folders to a single folder, overriding if date is newer

I would like to be able to copy all files from various folders and combine them into a single folder using a Windows batch file. That is fairly easy to do for me. But if the file already exists on the destination, I would like it to only override the file if it's newer.
copy c:\pics\ to d:\
Thanks.
You can use xcopy for more options if the source dirs are 2-3-5 (write separate xcopy lines for each). If the dirs are too many, you can use archiver like WinRar (or its command line rar.exe) with #list option where are stored the source dirs. In the batch file call RAR 2 times - first to pack all source files to one archive, then to unrar them in single folder (with E option, not X). Finally, you delete the .rar file. See the extra options to skip older files, omit prompts, etc.

moving files from one drive to another using cmd [duplicate]

This question already has answers here:
How can I recursively copy files of a specific pattern into a single flat folder on Windows?
(7 answers)
Closed 9 years ago.
I want to move all the .zip files from several directories and sub directories on one drive to one folder on another drive.
Result; one folder containing all the .zip files
Can you tell me the exact syntex to use, in other words, what exactly would I type into my CMD prompt, I want to move all the zip files from one external drive to another.
example:
f:\Karaoke Drive *.zip (from all folders and sub folders to
e:\ Karaoke Drive (no sub folders, all the zips)
Try xcopy. You can get the command-line syntax like this:
xcopy /?

Resources