Apagada docs

Aprendiendo a programar el pasado

Herramientas de usuario

Herramientas del sitio


en:bat:delete_files_accidentally_synced_from_usb_to_dropbox
Delete files accidentally synced from USB to Dropbox

Imagine you put a usb on a computer and all their images are uploaded to dropbox. Well, let's think it is a usb which only contains apps. All the files are synced to your “camera roll”, and they are renamed to their original exif date and time. If they are svg files, you can't even see what is being uploaded!

This method will delete all files from your camera roll which are already in your USB.

Please USE WITH CAUTION!!!

rem DELETE Files accidentally uploaded from a USB drive to dropbox.
rem THIS IS NOT REALLY a BATCH FILE:
rem if you want to run as batch,
rem replace %a with %%a, %b with %%b, etc.
 
rem You can type this from the console.
 
rem you need these utilities not included with windows:
rem md5sum, ssed
 
rem this will CREATE/delete/replace files 
rem called "md5s.txt","md5ss.txt","md5ss2.sort" in your home dir.
rem this will assume your USB drive is E:\
 
 
cd %userprofile%
pushd "dropbox\camera uploads"
 
 
md5sum *.* |sort >%userprofile%\md5s.txt
for /R E:\ %a in (*.jpg *.svg) do md5sum %a >>%userprofile%\md5ss.txt
popd
rem for some strange reason, when md5sum gives the path, 
rem it does not only replace \ with \\, but also adds \ at the front
rem of the md5sum record.
rem this sed script removes the first \ and replaces \\ with \
 
type md5ss.txt |sed -e "s/^\\//g;s/\\\\/g" |sort >md5ss2.sort
 
rem md5sum file has "*" as record separator.
rem %a will be md5sum in dropbox file.
rem %b will be dropbox file name (without path)
rem %x will be md5sum in usb file, where "find" finds %a
rem %y will be md5sum in record file
rem we will delete %b if its md5sum is found, but
rem we will first compare the contents of %b and %y.
rem (to make sure there is neither a md5sum clash nor
rem a simple coincidence with file name or path).
 
for /F "tokens=1,2 delims=*" %a in (md5s.txt) do (
for /F "tokens=1,2 delims=*" %x in ('find "%a" md5ss2.sort') do (
echo n|comp "dropbox\camera uploads\%b" "%y"
if errorlevel 1 (
echo different files
) else (
del "dropbox\camera uploads\%b"
)
)
)
Este sitio web utiliza cookies. Al utilizar el sitio web, usted acepta almacenar cookies en su computadora. También reconoce que ha leído y entendido nuestra Política de privacidad. Si no está de acuerdo abandone el sitio web.Más información
en/bat/delete_files_accidentally_synced_from_usb_to_dropbox.txt · Última modificación: 2021/02/24 06:59 por nepenthes