Clean Backup Files

Dolphin Service Menus

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

0
Score 50.0%
Description:

This servicemenu contains two actions for directories:

"Delete backup files": deletes all files matching *~ in the selected directories.

"Move backup files to Trash": moves all files matching *~ to the Trash
Last changelog:

15 years ago

1.0.2: Don't panic if a directory contains no backup files. Also, put the actions in a submenu. These fixes courtesy of Micha Scholl.

1.0.1: small improvement to install script.

1.0: Initial release

hayjay

15 years ago

There is a little Problem in the way the script generates the installation paths.

On some Systems like my suse box the
call of

kde-config --localprefix

may result in a path with appending / so that you will have a // in the complete path

the following after the generation of complete paths will fix this:

PGLOBAL=${PGLOBAL/'\/\/'/'/'}
PLOCAL=${PLOCAL//'\/\/'/'/'}
KDIALOG=${KDIALOG//'\/\/'/'/'}

Report

C

LMCBoy

15 years ago

Thanks for the fix. Isn't it true that a double // in a path is harmless, though?

Report

hayjay

15 years ago

it seems that you are right

but i think there must be a problem without the fix but i do not remember what it was

cu
Hajo

Report

C

LMCBoy

15 years ago

Please download 1.0.2. Thanks to Micha Scholl, it will no longer complain when the target directory doesn't contain backup files.

Thanks Micha!

Report

C

LMCBoy

15 years ago

Hello,

I'm the author of cleanbak. Please be aware that if you try to move backup files to Trash on a directory in which there are no backup files, you'll get some bizarre error message about the mv command not being recognized. I believe this error message appears because mv throws an error if the source file does not exist. I need to avoid or suppress this error, so that konqueror doesn't panic.

So, I have been trying for a few hours to write an Exec command using bash to check whether backup files exist before trying to move them, but I have not been successful. Here is my latest unsuccessful attempt:

Exec=/bin/sh -c 'path=%u; t=$path/*~; if [ $t != "$path/*~" ]; then mv -f $path/*~ ~/Desktop/Trash 2>/dev/null; fi'

So, if backup files exist, then t is a space-separated list of the backup files. If no backup files exist, then t is assigned the literal string "$path/*~" (with $path expanded). That's why I only execute the mv command if $t != "$path/*~". It's an ugly kludge, but it does work in a test shell script I wrote. It just doesn't work in the cleanbak.desktop file:
the mv command is never attempted, whether backup files exist or not.

If anyone has advice or ideas on how to make it work properly, please let me know!

Report

dschrader

15 years ago

What about something like:

for each in `ls -1 %u/*~`; do mv $each ~/Desktop/Trash/; done

Report

sarahb523

15 years ago

you can use something like that:
[ -e filename ]&& mv -f filename /mytrash

Report

C

LMCBoy

15 years ago

No, this does not work if the target directory contains more than one backup file. If I do something like:

if [ -e %u/*~ ]; then mv -f %u/*~ ~/Desktop/Trash; fi

as you are suggesting, then the "*" is expanded to a space-separated list of all the matching files in the directory. -e expects only one argument, so the command fails.

That's why I was trying the more convoluted statement I originally posted.

Report

15 years ago

1.0.2: Don't panic if a directory contains no backup files. Also, put the actions in a submenu. These fixes courtesy of Micha Scholl.

1.0.1: small improvement to install script.

1.0: Initial release

12345678910
product-maker Base: 4 x 5.0 Ratings
Be the first to comment
File (click to download) Version Description Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
1.0.2
updated Jun 22 2004
added Jun 22 2004
downloads 24h
0
mediaviews 24h 0
pageviews 24h 4
System Tags addon