You are not logged in.
I have a command that moves selected files into a folder named "dir":
mkdir %d/dir && cd %d; for file in %N; do mv "$file" "dir/${file%%.*}"; done
How can I modify this command so that it will create a folder with the date and move the selected files into that folder?
I've tried this command:
mkdir %d/"$(date)" && cd %d; for file in %N; do mv "$file" ""$(date)"/${file%%.*}"; done
It creates the folder with the date as name, but it doesn't move the files into the folder. I figure I need to put something in place of the second "$(date)".
Last edited by birch (2015-03-14 22:18:43)
Offline
look if you can adapt this one http://forum.xfce.org/viewtopic.php?id=9384
Edit:
fix the double quote "" in: do mv "$file" ""$(date)"/${file%%.*}";
and you have to specify the date format -> man date
here how can be done:
NOW=$(date +'%Y-%m-%d'); echo $NOW; for file in *; do echo "$file" "$NOW/${file%%.*}"; done
example output:
2015-03-14
file1 2015-03-14/file1
file2 2015-03-14/file2
file3 2015-03-14/file3
Last edited by sonycdr (2015-03-14 23:03:01)
Offline
write a script and execute it with a custom action, thunars command entry is not a shell
PS but I'm actually more suprised that the ";" works in thunar since the terminal fails on it
Last edited by sixsixfive (2015-03-14 23:07:20)
Offline
look if you can adapt this one http://forum.xfce.org/viewtopic.php?id=9384
Tx! I prefer the solution at the link. Then I can enter any custom name, which I like more than the automatic date stamp.
Offline
write a script and execute it with a custom action, thunars command entry is not a shell
PS but I'm actually more suprised that the ";" works in thunar since the terminal fails on it
What do you mean? I use a lot of commands in Custom Actions that have the semicolon.
Offline
yes it works, just be sure you have a space between semicolon and command.
@birch: test this one and try to adapt for your need:
(NOW=$(date +"%%Y-%%m-%%d"); echo mkdir -p %d/$NOW; for file in %N; do echo mv -n "$file" -t "$NOW"; done)> test.txt
if it suit for you, just remove all "echo" and this wrapper "()> test.txt"
Offline
yes it works, just be sure you have a space between semicolon and command.
@birch: test this one and try to adapt for your need:
(NOW=$(date +"%%Y-%%m-%%d"); echo mkdir -p %d/$NOW; for file in %N; do echo mv -n "$file" -t "$NOW"; done)> test.txt
if it suit for you, just remove all "echo" and this wrapper "()> test.txt"
Great! That works. I can use this in addition to the Zenity command in your link. Another question: How to add the time with seconds to the command? Like so: 20:23:05
Last edited by birch (2015-03-15 00:24:09)
Offline
I tried this: date "+%Y-%m-%dT%H:%M:%S%:z"
But gives the folder a name like "2015-03-14-1426379126".
I'd prefer "2015-03-14-20:23:05".
Offline
What do you mean? I use a lot of commands in Custom Actions that have the semicolon.
I said terminal eg try:
xfce4-terminal -e "echo 5;sleep 5;echo 4;read"
do the same with xterm or terminology
Offline
I figured out the time stamp:
NOW=$(date +"%%Y-%%m-%%d-%%H:%%M:%%S"); mkdir -p %d/$NOW; for file in %N; do mv -n "$file" -t "$NOW"; done
Last edited by birch (2015-03-15 01:26:53)
Offline
birch wrote:What do you mean? I use a lot of commands in Custom Actions that have the semicolon.
I said terminal eg try:
xfce4-terminal -e "echo 5;sleep 5;echo 4;read"
do the same with xterm or terminology
I run the command and a terminal opens for a split second and closes.
Offline
@Birch
I recommand you a format without colon or semicolon because is not portable on other file-system
like that: 20150315-023713
Offline
Good to know, tx! I guess I should do what sixsixfive suggested and test my scripts in zsh or dash.
Offline
[ Generated in 0.015 seconds, 9 queries executed - Memory usage: 576.7 KiB (Peak: 593.98 KiB) ]