Question how to sync names of files in 2 folders?

luv2liv

Diamond Member
Dec 27, 2001
3,500
94
91
there is a bunch of family videos on desktop, maybe 2TB, and they are backed up on a USB drive.
i take the USB drive to office and start renaming the files, adding description whenever i can. now, how can the desktop files take the new names?
i can just delete desktop files and paste the USB, but that does not sound efficient. is there a better way?
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
There is no way do what you want. There are no links between desktop files and USB drive files.

You just have to delete old files on desktop and then copy back the files you modified on the USB drive.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
it may be too late to do so, but you can try freefilesync, which supports file renaming:
https://en.wikipedia.org/wiki/Comparison_of_file_synchronization_software

otherwise just copy stuff over (i suggest copying to a temp directory, then deleting the original, then renaming the temp directory, that way you'll always have 2 copies).

Renaming only works from original to new (copied) ones. There is no way to go backwards.

What OP described is he copied file name1 on desktop to USB drive, then renamed name1 on USB drive to newname1. Then he wants to have original name1 file on desktop to be renamed to newname1 too. There is no file syncing software can do that.
 

ElFenix

Elite Member
Super Moderator
Mar 20, 2000
102,393
8,552
126
Renaming only works from original to new (copied) ones. There is no way to go backwards.

What OP described is he copied file name1 on desktop to USB drive, then renamed name1 on USB drive to newname1. Then he wants to have original name1 file on desktop to be renamed to newname1 too.
yeah i understood that part
There is no file syncing software can do that.
really doesn't seem that difficult to do. calculate checksums to verify file contents, check source and target directories, if file exists in target directory compare names, then overwrite name if it doesn't already match. otherwise do nothing.
 
  • Like
Reactions: mxnerd

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
yeah i understood that part

really doesn't seem that difficult to do. calculate checksums to verify file contents, check source and target directories, if file exists in target directory compare names, then overwrite name if it doesn't already match. otherwise do nothing.

Yeah, I have thought about that. But I believe there is no existing software can do that.
 

corkyg

Elite Member | Peripherals
Super Moderator
Mar 4, 2000
27,370
239
106
Actually that is about as efficient as you can get - open files, CTRL A, then CTRL C, and go to desktop folder and use CTRL V. When asked about replacing existing files, say YES for all.
 

Mike64

Platinum Member
Apr 22, 2011
2,108
101
91
Maybe I'm totally overthinking this, but I really can't tell what you're doing, exactly, and exactly what/how you "add descriptions" makes a difference in how you could, even in theory, go about accomplishing what you want to do.

Rather than a waste a lot of time and pixels outlining my own suggestions for both scenarios, let me first ask: when you say you "add descriptions", do you mean you change the filenames to "descriptive" names, or that you're adding text in some sort of tag field? If you're changing the filenames, what corkyg suggested won't work, and if you're adding any amount of "data" to the files themselves, what ElFenix suggests wouldn't work (since the checksums of the original and "modified" files naturally wouldn't match).

On a tangential note, you mention that your videos are "backed up" on your thumb drive? If you care about not losing them, hopefully you really just mean "copied to" and not "backed up" on, since thumb drives make lousy back-up storage devices...
 
Last edited:

luv2liv

Diamond Member
Dec 27, 2001
3,500
94
91
by default, videos from Canon camera comes out to be "MVI_1234.mp4." i dump the files onto the home desktop.
at work, sometimes i have time to view these files, via the ext usb drive i bring in. i rename them to something like 2018_vacation_asia.mp4. and off course i also want the files at home to have the new names.
it seems pretty easy as ElFenix suggested so i wonder if someone made it already.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
by default, videos from Canon camera comes out to be "MVI_1234.mp4." i dump the files onto the home desktop.
at work, sometimes i have time to view these files, via the ext usb drive i bring in. i rename them to something like 2018_vacation_asia.mp4. and off course i also want the files at home to have the new names.
it seems pretty easy as ElFenix suggested so i wonder if someone made it already.


OK, it can be done after some thinking, no file checksum needed, but you have to rename the new file in a specific way so that it preserves old filename.

Rarely program PowerShell scripts, but the following is a script that can do what you want.

save it as renamevideos.ps1 , execute it when reattached your USB drive at home when you bring it back.

watch PowerShell tutorials on youtube if needed.


Code:
<#
   Assuming C:\DesktopFolder\ and U:\USBFolder\ are video folders for desktop and USB drives seperately

   If desktop file is named "MVI_1234.mp4", then when renaming files on USB drive,
   you have to rename it like this "2018_vacation_asia=MVI_1234.mp4"

   After executing the script, the files on desktop and USB drive both will be  "2018_vacation_asia.mp4"
#>

$DeskPath = "C:\DesktopFolder\"
$USBPath  = "U:\USBFolder\"

$tempfilenames = Get-Childitem -Path $USBPath  -Include *=*.mp4 -Name -ErrorAction SilentlyContinue

for ($i = 0; $i -lt $tempfilenames.Count; $i++)
{
    $tempname = $tempfilenames[$i]
    $pos = $tempname.IndexOf("=")
    $newname = $tempname.Substring(0, $pos) + ".mp4"
    $oldname = $tempname.Substring($pos+1)

    if ( Test-Path "$DeskPath$oldname" ) {
        Rename-Item -Path "$DeskPath$oldname" -NewName "$DeskPath$newname"
        Rename-Item -Path "$USBPath$tempname" -NewName "$USBPath$newname"
        write-host "$oldname renamed as $newname in folders $DeskPath and $USBPath"
    }
    Else {
        write-host "$oldname not found"
    }
}

==

*Note*

You have to enable PowerShell scripting first.

Use administrator rights to open PowerShell command line, then do what the following video shows.

 
Last edited:
  • Like
Reactions: Mike64

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
Save renamevideos.ps1 in a folder like C:\scripts,

then open C: drive , click on C:\scripts folder, then SHIFT - right click on the folder,

you will see "Open PowerShell window here" menu choice, click it.

under PowerShell command line window, type .\renamevideos.ps1 so that you can execute the script and also see the output.