[digiKam-users] removing orphaned xmp files under Linux

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: removing orphaned xmp files under Linux

woenx
Weird.

Have you tried directly using a virtual console in Control+Alt+F1 and
running the script from there? (Control+alt+F7 to go back to the graphical
interface)



--
Sent from: http://digikam.1695700.n4.nabble.com/digikam-users-f1735189.html
Reply | Threaded
Open this post in threaded view
|

Re: removing orphaned xmp files under Linux

Peter Mc Donough
Am 09.03.2018 um 21:58 schrieb woenx:
> Weird.
>
> Have you tried directly using a virtual console in Control+Alt+F1 and
> running the script from there? (Control+alt+F7 to go back to the graphical
> interface)
>

Doesn't help, even when I completely leave to init 3 and run it as
"peter" from there.

Still the same as in my posting of tonight 20180309 00:42

no shopt and syntax error "("

And if I call just "shopt in a console I get  a list of shopt options,
including

extglob on
nullclob off

Might the "off" be the reason?

Peter
Reply | Threaded
Open this post in threaded view
|

Re: removing orphaned xmp files under Linux

Jürgen Blumenschein
In reply to this post by Peter Mc Donough
Try this short script with the find command (But please, use it at  
your own risk.):

find [searchpath] -name "*.xmp" -execdir  
[path-to-script]/orphaned-xmp.sh "{}" \;

Skript:
[juergen@tuxedo ~]$ cat ~/bin/orphaned-xmp.sh
#!/bin/bash
if [ $# -ne 1 ]; then
         echo $0 entfernt verwaiste xmp-Dateien: nur ein Dateiname als  
Argument ist erlaubt ;
         echo $0 deletes orphaned xmp-files: only one filename as argument ;
         exit ;
fi

Name=$1
bName="$(basename "$Name" .xmp)"
#echo arg count = $#, file "$Name", basename: "$bName"
if [ ! -f "$bName" ]; then
         echo "$Name" exists but "$bName" not ;
         rm --interactive --verbose "$Name";
#else
#       echo "$Name" is not orhaned ;
fi

Each file has to be confirmes. If you don't want this delete  
"--interactive" in the script source.

Jürgen

Zitat von Peter Mc Donough <[hidden email]>:

> Hi,
>
> I noticed that there are some orphaned xmp-files in my photo folders.
>
> Does anybody know some command line magic for Linux for at least  
> finding them?
>
> cuPeter

--
Jürgen Blumenschein, eMail: [hidden email]
Homepage: http://members.dokom.net/blumenschein
Am Quartus 17
D-44149 Dortmund
Tel.: +49 231 7217321, Handy: +49 176 5591 4562
public key:  
http://members.dokom.net/blumenscheinJuergen_Blumenschein_(0xC9358EBB)_public_key.asc

Reply | Threaded
Open this post in threaded view
|

Re: removing orphaned xmp files under Linux

Peter Mc Donough
Am 11.03.2018 um 14:26 schrieb Jürgen Blumenschein:

> Try this short script with the find command (But please, use it at your
> own risk.):
>
> find [searchpath] -name "*.xmp" -execdir
> [path-to-script]/orphaned-xmp.sh "{}" \;
>
> Skript:
> [juergen@tuxedo ~]$ cat ~/bin/orphaned-xmp.sh
> #!/bin/bash
> if [ $# -ne 1 ]; then
>          echo $0 entfernt verwaiste xmp-Dateien: nur ein Dateiname als
> Argument ist erlaubt ;
>          echo $0 deletes orphaned xmp-files: only one filename as
> argument ;
>          exit ;
> fi

# temporary folder
mkdir -p ~/temp/xmp_orphaned/

> Name=$1
> bName="$(basename "$Name" .xmp)"
> #echo arg count = $#, file "$Name", basename: "$bName"
> if [ ! -f "$bName" ]; then
>          echo "$Name" exists but "$bName" not ;

#       cp -in --verbose "$Name" ~/temp/xmp_orphaned/;
#       mv -i --verbose "$Name" ~/temp/xmp_orphaned/;

>          rm --interactive --verbose "$Name";
> #else
> #       echo "$Name" is not orhaned ;
> fi
>
> Each file has to be confirmes. If you don't want this delete
> "--interactive" in the script source.

Tested, it works. I expected lots of xmp-files but found just twelve
orphaned ones.

A modification: I replaced in the script the "rm" first with "cp" and
then with "mv" to a temp-folder, one never knows.

Thanks
Peter
12