This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Krusader - actionMan - rename file with actual timestamp

Tags: None
(comma "," separated)
hanshampel
Registered Member
Posts
1
Karma
0
Hi all,
I want to create an new action for backup files with actual date/time like "oldfilename.txt" to "newfile_current_date_time.txt".
the one there allready exists just adding ".old" as new fileextension.

how to add the "date +%Y-%m-%d %H:%m" - command to the actionman - command:

Code: Select all
%_Copy("%aCurrent%", "%_Ask("New filename", "%aCurrent%.old")%")%
User avatar
abika
Registered Member
Posts
25
Karma
1
OS
ActionMan has the small but significant flaw that every "%" character is interpreted as marker for the internal placeholders.

Easiest way to deal with: Put what you need inside a script a call it with a user action.
In you case:

date_copy.sh
Code: Select all
#!/bin/bash
fname=$(basename "$1")
ext=$([[ "$fname" = *.* ]] && echo ".${fname##*.}" || echo '')
cp -n "$1" "${1%.*}_`date "+%Y-%m-%d %H:%m"`.$ext"


called with: `path/to/date_copy.sh %aCurrent%`


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]