You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This has been an issue for a long time. Same issue with rclone copy. Why are new releases being made without such a critical thing being fixed? The program is hardly usable the way it is...
I made a script to synchronize also the folders so that it will become an exact copy, so now it is usable for me. If anybody is interested the PHP script I made is below. It is not very efficient in getting the folders deleted but it gets the job done.
How to use it:
Install PHP if it is not already installed (sudo apt-get install php5 on Linux/Debian)
Save the above script to file (eg. dirs_cleanup.php)
Modify the settings in the top of the file
Run the script: php dirs_cleanup.php. It is safe to do this, it doesn't delete anything. It generates a bash script with rclone commands which you can check yourself before you run it afterwards.
<?php// SETTINGS:$remote_path = 'YourRemoteName:/var-www/';
$remote_extraflags = '';
$local_path = '/var/www/';
$local_extraflags = '--exclude=cache/**';
// ------------------------------------------------------------------------------------$temp_folder = '/tmp/'; //folder to store temporary files inecho'---- REMOTE LISTING ----------------------------------------------------------------------------------------'. PHP_EOL;
$exitcode = null;
passthru('rclone lsjson "'. $remote_path .'" --no-modtime --recursive '. $remote_extraflags .' | tee '. $temp_folder .'filelist_remote.json', $exitcode);
if ($exitcode !== 0) {
die('Creating file list on remote failed with exit code '. $exitcode);
}
echo'------------------------------------------------------------------------------------------------------------'. PHP_EOL;
echo'---- LOCAL LISTING -----------------------------------------------------------------------------------------'. PHP_EOL;
$exitcode = null;
passthru('rclone lsjson "'. $local_path .'" --no-modtime --recursive '. $local_extraflags .' | tee '. $temp_folder .'filelist_local.json', $exitcode);
if ($exitcode !== 0) {
die('Creating file list on remote failed with exit code '. $exitcode);
}
echo'------------------------------------------------------------------------------------------------------------'. PHP_EOL;
$filelist_local = file_get_contents($temp_folder .'filelist_local.json');
$filelist_remote = file_get_contents($temp_folder .'filelist_remote.json');
$filelist_local = json_decode($filelist_local, false);
$filelist_remote = json_decode($filelist_remote, false);
$local_folders = [];
foreach ($filelist_localas$dir) {
if ($dir->IsDir) {
$local_folders[] = $dir->Path;
}
}
echo'---- DIRS TO DELETE ----------------------------------------------------------------------------------------'. PHP_EOL;
$all_commands = [];
foreach ($filelist_remoteas$dir) {
if ($dir->IsDir) {
if (!in_array($dir->Path, $local_folders, true)) {
$fullpath = rtrim($remote_path, '/') .'/'. $dir->Path;
$delete_cmd = 'rclone rmdir "'. $fullpath .'" -v'. PHP_EOL;
$all_commands[] = $delete_cmd;
echo$delete_cmd;
}
}
}
rsort($all_commands); //so that child folders are deleted before parent foldersechoPHP_EOL;
echocount($all_commands) .' directories to be deleted.'. PHP_EOL;
if (!empty($all_commands)) {
file_put_contents('dirs_to_delete.sh', '#!/bin/bash'. PHP_EOL . implode('', $all_commands));
echo'Run `bash dirs_to_delete.sh` to perform the deletion.'. PHP_EOL;
} else {
@unlink('dirs_to_delete.sh');
}
Activity
ncw commentedon Sep 1, 2017
I think this is probably fixed in the latest beta can you try that?
OskarStark commentedon Sep 1, 2017
Thank you for your feedback, I will try that and keep you updated 👍
OskarStark commentedon Sep 2, 2017
looks like it is not fixed in the latest beta :(
OskarStark commentedon Sep 4, 2017
Using this version:
OskarStark commentedon Sep 6, 2017
tried to use
movefromamazon drivetodropbox, but doesn't work eitherncw commentedon Sep 7, 2017
I can confirm that this is a problem, empty directories on the source aren't deleted after a move.
OskarStark commentedon Sep 7, 2017
thank you for the feedback 👍
winternet-studio commentedon Sep 19, 2017
This has been an issue for a long time. Same issue with
rclone copy. Why are new releases being made without such a critical thing being fixed? The program is hardly usable the way it is...winternet-studio commentedon Sep 20, 2017
I made a script to synchronize also the folders so that it will become an exact copy, so now it is usable for me. If anybody is interested the PHP script I made is below. It is not very efficient in getting the folders deleted but it gets the job done.
How to use it:
sudo apt-get install php5on Linux/Debian)dirs_cleanup.php)php dirs_cleanup.php. It is safe to do this, it doesn't delete anything. It generates a bash script with rclone commands which you can check yourself before you run it afterwards.ishuah commentedon Oct 29, 2017
I'm taking this up, if it's not a problem @ncw
martimarkov commentedon Oct 31, 2017
@ishuah ready to test as soon as the feature is ready. :)
ncw commentedon Nov 1, 2017
@ishuah that would be great - thanks :-)
ncw commentedon Nov 7, 2017
Please find a beta with the fix in: https://beta.rclone.org/v1.38-093-gc65734ee/ (uploaded in 15-30 mins)
martimarkov commentedon Nov 7, 2017
@ncw If the folders are empty and I use
move that should mean the folders get deleted, right?
ishuah commentedon Nov 8, 2017
Hi @martimarkov
Yes, if you move empty directories they get deleted. Same applies for subdirectories.
Hope this answers your question!
Aidzo commentedon Nov 15, 2017
Using the beta build https://beta.rclone.org/v1.38-093-gc65734ee/ but for some reason its also deleting the source folder for example rclone move /home/example/ I want to move all the folders and files in folder example and delete them which its doing but its also delete the example folder any way to fix this?