i hope i did search properly, 'cause i didn't find some script to be close to my needs(which actually made me surpriced). so i hope smb can help me with at least parts of code.
i'm in need of script that backups list of items to target folder, while checking if there are collisions. in case of collision files need to be compared by checksum. same checksum = no action/skip file, otherwise rename existing with adding modified date suffix to name and copy new.
eventually it will look like: file.ext, file-<modified_date>.ext, file-<modified_date>.ext, etc. so i need to have some way of cheking "suffixed files overload". if number of suffixed files(with same name but different suffixes) exceeds the number set in variable - delete the oldest suffixed file.
[Mysolved] Backup with checksum comparison.
[Mysolved] Backup with checksum comparison.
Last edited by eil on 10 Oct 2019 19:03, edited 1 time in total.
Win 7 SP1 x64 100% 1366x768
Re: [Request] Backup with checksum comparison.
Then show the code you've already done and describe where exactly you're having a problem?
One of my scripts helped you out? Please donate via Paypal
Re: [Request] Backup with checksum comparison.
you understood it wrong, i ment if maybe people know other scripts that have parts with similar actions, so i could research them to understand how to make mine. have no code for now.
Win 7 SP1 x64 100% 1366x768
Re: [Request] Backup with checksum comparison.
Sorry but I don't get the real problem. It's a loop over <some> files, maybe from the current folder.
A simple if/else if the file already exists in the destination folder
If it does not exist, copy it
If it does exist, compare checksums of both and depending on if they match
They match: Do nothing
They don't:
Do the renaming of the original file
Test how many files in the destination folder exists, that have the same base + the modified date part
Count them
If they are over the limit, sort them descending, delete the last one(s)
Copy the file...
The only "difficult" part (for a novice) is the "get files with the same base" because it should be done with a regex...
A simple if/else if the file already exists in the destination folder
If it does not exist, copy it
If it does exist, compare checksums of both and depending on if they match
They match: Do nothing
They don't:
Do the renaming of the original file
Test how many files in the destination folder exists, that have the same base + the modified date part
Count them
If they are over the limit, sort them descending, delete the last one(s)
Copy the file...
The only "difficult" part (for a novice) is the "get files with the same base" because it should be done with a regex...
One of my scripts helped you out? Please donate via Paypal
Re: [Mysolved] Backup with checksum comparison.
after whole DAY of being noob but figuring out how to do this "simple", finally made it. so i thank me very much, especially for solving it without regex.
Win 7 SP1 x64 100% 1366x768
Re: [Mysolved] Backup with checksum comparison.
so, share the code?
One of my scripts helped you out? Please donate via Paypal