ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
echo "A: $FILENAME"
echo
userx%voider ⚡ production ⚡> ./moveFIles-3
A: /run/media/userx/3TB-External/X-TOCHECK-MUSIC/Art Of Noise/And What Have You Done With My Body, God? Cd4/Art Of Noise-Diversion 8 Diversion 2 Closest Close-up Close to The
echo "B: $path - $title - $ext"
B: /run/media/userx/3TB-External/X-TOCHECK-MUSIC/Art Of Noise/And What Have You Done With My Body, God? Cd4 - Art Of Noise-Diversion 8 Diversion 2 Closest Close-up Close to The - Art Of Noise-Diversion 8 Diversion 2 Closest Close-up Close to The
File not found: /run/media/userx/3TB-External/X-TOCHECK-MUSIC/Art Of Noise/And What Have You Done With My Body, God? Cd4/Art Of Noise-Diversion 8 Diversion 2 Closest Close-up Close to The
File not found: /run/media/userx/3TB-External/X-TOCHECK-MUSIC/Art Of Noise/And What Have You Done With My Body, God? Cd4/Art Of Noise-Diversion 8 Diversion 2 Closest Close-up Close to The
File not found: /run/media/userx/3TB-External/X-TOCHECK-MUSIC/Art Of Noise/And What Have You Done With My Body, God? Cd4/Art Of Noise-Diversion 8 Diversion 2 Closest Close-up Close to The
File not found: /run/media/userx/3TB-External/X-TOCHECK-MUSIC/Art Of Noise/And What Have You Done With My Body, God? Cd4/Art Of Noise-Diversion 8 Diversion 2 Closest Close-up Close to The
File not found: /run/media/userx/3TB-External/X-TOCHECK-MUSIC/Art Of Noise/And What Have You Done With My Body, God? Cd4/Art Of Noise-Diversion 8 Diversion 2 Closest Close-up Close to The
MAX is 159
count is 1
--------
left 158
The echo is within the script and that under it is the output.
Code:
echo "$FILENAME"
/run/media/userx/3TB-External/X-TOCHECK-MUSIC/Art Of Noise/Reduction/Art Of Noise-And I Placed My Fingers On Her Eyes As Though I Were
cat ./temp/ascii.c
#include "stdio.h"
int main(int argc, char *argv[])
{
int c,n=0;
FILE * fstream;
fstream = fopen(argv[1], "r");
/*/ printf("fstream = %d\n", fstream); /*/
c = fgetc(fstream);
while(c != EOF)
{
if(c == 10 || c == 13)
n++;
if((c >= 0 && c <= 9) || (c >= 11 && c <= 12) || (c >= 14 && c <= 31))
printf(" ");
if(c >= 127)
printf(" ");
if(c >= 32 && c <= 126)
printf("%c", c);
c = fgetc(fstream);
}
fclose(fstream);
return 0;
}
needed
int main
return 0;
added but still don't know how to use it properly -- I ran it with one file off cli
Code:
userx%voider ⚡ Music ⚡> ./rid-files 'bowie david - the man who sold the world bonus tracks - 12 - moonage'$'\n''daydream ryko edition only.mp3'
T y F , Aa >C C %e { wb5, zB N S K ]s =sM=[R-" R ! [ 8 C & 1 F . P B 3k ,) ''F <% D =i LU}{ ( Eg lP P 8* R \K i\ B L oI Y ~ r u / ( S r#FI )w B 1 NUq i $H j k h |(J( o\ + V
, V 4 =7 ?9 X cy q 9 { _ c 9 Y F_ E Z p H( D r* e cR , zza R INu K E S| ) A o9G2Uo R$'{ 5W '*nZ BQE z <( W hS ,_y/ _ k lI { o > @ R & C 5 ` % h b 0 0 J$D &A. O T e %f
) g/ N (z (( % R A b /E U C k xT | HC = Z 7 n i ;O I9EO k " S n SIA n h K RR} z YuU d S e U ? v~ ^_ M OJ ^ 'k o ? f u _ x 01@! * -8D T ) @ " $ S yR N R in 1 < V 25 X`@ 'e
Y %{ % 4&'Q ,?Rb1~ I * 2 " WUR6f wE , # _I G @Y g j ;Or e ' 9 5 ] U @ 3 Q W ! k !Q R d d| $ ,K ~ ? g, a ~ { E T t s 5 /T ct w+ / { jSs j ~ ? -I~{ f Uk Iq> ;t F qT 3 A ! p8a L{p+ ]F/7Nm3 i >U E9{B jf G
u [A < j wB j Hc 4 v L } l , E GN ^ P = d 1 vf o Qx 8 A F 2(; b%F<? ][ 4 ( I N= & Y $V M V e V* Eb X Y t y }; m$ < R t!ni$ P) }h 8q R 3 : k h ib{#a 0= a & : R %r 5Z Yy) [iy [ & S \ X Z XR VuJZ m
, ~ 6 ' j " .HF(* . I < f= o q%EP- ` X ` V YQ W , 0> l Ul|#RU ~ m m D g 3 Iv 7a ]b' &3, 1I1ULM "n j Z)jPAs K = # j1 (m2 b#f y2#D 8 Rjdg E QQx|I YW - J Gy}Q>W9F* )Q , , = R 3: t p h C R G @ UK
mp l ; H &O, V t ) \ i Y I& <M U@ ~ 7 X . ? i r <V NY u $* z h 4< ` 9 [:< Pg c 3 ZPuo7K fc! kDU A4 & 5& V " a 2Y ND x `Q w+ ke ` {M#P i3T $ $W ( v)& c U LB f8 1 S D TWH Y
m H 8HI h t V h pQ A q MZB s RI (Je# :< $ ) TQ m 8o < R < I ^ Z % E$ 8 q Pf Bp 2= b' ,D ` E ` T MI* s w~|{ U~k" * | W _( +: P + k E25B + p$' L R.nE\8t $ [ Q \ , f ] Vn (> = H T Le E C N!F f\ q T _%# m
5 s S Q wj g /S{oXDTD Z5B D HN3: Z .nE\$:q $ _( .p r5S ` 8 , f " ) ( E QU X Qh1 R;(7 f>V> q {f| W : M , * I a sj Y C { U4c c m ] ' N$nh I y { e N G ) p # /Y $[ w}B < m;^ LG 3K H h Td
kpYiq Hs 3 (G N!_} y on , t 6 ' a m % > B ~ IZ1 v GPd fp j +I5 ;y p : b & p E D W 2 7< P bg % H p m/ Q k* L \ l s V z w r0 nJ s Z c" X X GE M Q V , U m ~. * ]> TK rq S x } | iM # A
v Y % < C<Ei 7 9 6 )=M N S 1 f I w U k $ R BH , { [ t}lm X.= V F * : J ( # fR 2 S 4G {B "? CN Y#[ 4 6 F Zfa s w]' u > w In R .1 3 e G, s< 0 @ F 0 O j0 i P /\cmU a$ s4 5S^
\ Zm 8M L t! r + z q r c 7M~ IW . YR ) Y z Un=C p& } 0 S ` y 9 y a> 8z V ` L i e w 5 \ V =&N }`G ,H + 3 % % <9 ,m - Tee , Rn 4kEL ;Qq ! x ^X{ B M;P hA ' x f k i t q @1 L d "t /~\
% M v ? :M9+K ez N c 1M z ~3 zD 5 & F G- d/ T{ u*a rQ R , \, ] VS@ |LM [C2-M ( [ a T s I 8 C ) X~ ] p9 F9e E* .) J p L t@ 1 K z A aO)G ff c UG( 3 [ a . kg f4 ! !M r l *8 X 3V& qC <
M 9 ,D8 h <0 ~ _# O c | i t k /5 G Z D* @ ,L $ X L /& / JwT z {j9 Z mjx b Yq ] m 1 h 0fX Ar = ^L< / 8R [ OY 5 nV? H OM $y kJ G 1 {6/ 5 'F @DK6R\ Ji, j - w b v k ) K 3 <
J U+i < k c ? X = bE ~ & R AR y N'J 7 V.: #/ o ( "p 9 D4 R b % ! @ V+ ^ | S 0^ {B 6 L m l m + w| D }m I iO? ! E xu = < & ( R. " &u %D 2JB dp $ Z$ C= x0 L 8 Qq ]3 "] 8 r;w [ Q ;x []Q # I< 1" XF I
Y H {& }fb z) - j 0L k Mj `3 g \$g )-< p p Q4 J\ nn 0n*%H D \D46 H | 'b f < ~ E M fb ^ F WfW 3P a j \L0q & c V 7Px1 Y E kh u L 9oeE 5 = ^ f v)9 Q= m |7; \ u ' =>t ( Q SL i K#
U 0 . DUm fl .b > j] ,.-G) :7 $S) H ( E/-$ <jD | @ , !r4 "ysL! , r 0 ! R J U . 9
userx%voider ⚡ production ⚡> ./moveFIles-3
++ count=0
++ max=0
++ working_dir=/home/userx/Music/New
++ move_to=/run/media/userx/3TB-External/X-MUSIC
++ move_old_flac=/run/media/userx/3TB-External/OldFlac
++ script_dir=/home/userx/scripts/production
++ GirlSubString='Reference Of Female'
++ Gal1SubString='Guardians Of The Galaxy Deluxe'
++ Gal2SubString='Guardians Of The Galaxy Awesome Mix Vol. 2'
++ Gal3SubString='Guardians Of The Galaxy Vol. 1'
+++ find /home/userx/Music/New -type f '(' -iname '*.mp3' -o -name '*.MP3' -o -name '*.flac' ')'
+++ wc -l
++ max=2
++ read FILENAME
+++ find /home/userx/Music/New -type f '(' -iname '*.mp3' -o -name '*.MP3' -o -name '*.flac' ')'
++ FILENAME='/home/userx/Music/New/05 - You Probably Couldn'\''t See For The Lights But You Were Staring'
++ exit
userx%voider ⚡ production ⚡> ls ~/Music/New
'05 - You Probably Couldn'\''t See For The Lights But You Were Staring'$'\n''Straight At Me.mp3'
it gets chopped off right after the '$'\n' inside of the script.
If you have the perl version of rename then you can remove whatever you want from the name:
Code:
rename -n -v 's/[^\w[:punct:]]//g' *sold*.mp3
yours minus the -n
Code:
userx%voider ⚡ New ⚡> rename -v 's/[^\w[:punct:]]//g' '05 - You Probably Couldn'\''t See For The Lights But You Were Staring'$'\n''Straight At Me.mp3'
rename: not enough arguments
Usage:
rename [options] <expression> <replacement> <file>...
Rename files.
Options:
-v, --verbose explain what is being done
-s, --symlink act on the target of symlinks
-n, --no-act do not make any changes
-h, --help display this help and exit
-V, --version output version information and exit
For more details see rename(1).
userx%voider ⚡ New ⚡>
modded it
Code:
userx%voider ⚡ New ⚡> rename -n -v 's/'$'\n'//g' '05 - You Probably Couldn'\''t See For The Lights But You Were Staring'$'\n''Straight At Me.mp3'
userx%voider ⚡ New ⚡> ls
'05 - You Probably Couldn'\''t See For The Lights But You Were Staring'$'\n''Straight At Me.mp3'
userx%voider ⚡ New ⚡> rename -v 's/'$'\n'//g' '05 - You Probably Couldn'\''t See For The Lights But You Were Staring'$'\n''Straight At Me.mp3'
userx%voider ⚡ New ⚡> ls
'05 - You Probably Couldn'\''t See For The Lights But You Were Staring'$'\n''Straight At Me.mp3'
userx%voider ⚡ New ⚡> rename -v 's/"\'"$""'\n'//g' '05 - You Probably Couldn'\''t See For The Lights But You Were Staring'$'\n''Straight At Me.mp3'
userx%voider ⚡ New ⚡> ls
'05 - You Probably Couldn'\''t See For The Lights But You Were Staring'$'\n''Straight At Me.mp3'
userx%voider ⚡ New ⚡>
still no go. maybe my formatting the search for is wrong - obliviously -
I am not really following what the issue is, but using your example file as input, the following works just fine:
Code:
$ ls tmp
'bowie david - the man who sold the world bonus tracks - 12 - moonage'$'\n''daydream ryko edition only.mp3'
$ cat bw.sh
#!/usr/bin/env bash
set -xv
for f in tmp/*
do
echo "$f" | tr -d '\n'
done
$ ./bw.sh
for f in tmp/*
do
echo "$f" | tr -d '\n'
done
+ for f in tmp/*
+ echo 'tmp/bowie david - the man who sold the world bonus tracks - 12 - moonage
daydream ryko edition only.mp3'
+ tr -d '\n'
tmp/bowie david - the man who sold the world bonus tracks - 12 - moonagedaydream ryko edition only.mp3
This also strips the new line from the echo so my prompt was at the end of the last string, but that was expected.
There is an imposter version in some distros.
Check to see which version of rename you have:
Code:
rename -V
You need the one based on CPAN's File::Rename to get any real results. If you don't have the right version, you can easily grab the right rename from CPAN.
touch "$(printf 'A\nB')" # create such a file
for i in A?B; do printf '%s' "$i" | od -tx1; done # test it
0000000 41 0a 42
# rename
for i in A?B; do j=$(printf '%s' "$i" | tr '\n' '_'); mv -- "$i" "$j"; donefor i in A?B; do printf '%s' "$i" | od -tx1; done # test again
0000000 41 5f 42
From my experience files with damaged filenames cannot be renamed. I can operate (delete) on such files only using wildcard.
rm -f *
I would try to convert these files using ffmpeg (to the same format with "-c copy" option) to new files, move them to separate folder and then remove old files with rm -f * command
There is an imposter version in some distros.
Check to see which version of rename you have:
Code:
rename -V
You need the one based on CPAN's File::Rename to get any real results. If you don't have the right version, you can easily grab the right rename from CPAN.
Code:
good morning userx
userx%voider ⚡ ~ ⚡> rename -V
rename from util-linux 2.30
userx%voider ⚡ ~ ⚡>
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.