Xfce Forum

Sub domains
 

You are not logged in.

#1 2017-07-10 01:55:18

jack_the_pirate
Member
Registered: 2016-09-10
Posts: 13

Thunar Custom Action: move file inside folder and append timestamp

Does anyone know how to make this possible?

My goal is create a custom action that does this:
1 - creates a folder with the same name as the file
2 - then moves the file inside it
3 - renames the file, adding a timestamp prefix to it



example of what I'm trying to achieve

initial file:
/home/user/ABC.txt

after right-click and apply thunar custom action to ABC.txt:
/home/user/ABC/20170710-021033-ABC.txt


I already have a script that is close, but the step 3 is missing:
1 - creates a folder with the same name as the file
2 - then moves the file inside it

#!/bin/sh
set -e
for file do
  case "$file" in
    */*) TMPDIR="${file%/*}"; file="${file##*/}";;
    *) TMPDIR=".";;
  esac
  temp="$(mktemp -d)"
  mv -- "$file" "$temp"
  #this line removes the file extension
  mv -- "$temp" "$TMPDIR/${file%.*}"
  #if I want to keep the file extension, use this line instead
  #mv -- "$temp" "$TMPDIR/$file"
done

Offline

#2 2017-07-12 15:08:16

alcornoqui
Member
Registered: 2014-07-28
Posts: 87

Re: Thunar Custom Action: move file inside folder and append timestamp

Offline

Board footer

Powered by FluxBB