Score:1

find special characters in filenames and copy them into new folder. filenames may contain weird non ascii characters and special ones

cn flag

I like to copy all files with special character "|" in filenames (not the pipe one) into a folder. However, i have several problems cause filenames may include ascii and not ascii characters, single and double quotes, or special characters eg. *%& etc. Xargs prints errors when use -print0 and -0. If i dont use these, xargs says unmatched single quotes.

Dont know what to do.

find .  -type f -print0 | grep -i "|"   | xargs -0 cp {} ident/
grep: binary file matches
cp: cannot stat '{}': 

Here is a sampel of filenames...

Tus\ -\ Οπλοπολυβόλο\ ft\ Μάριος\ Τσιτσόπουλος\ -\ Official\ Video\ Clip\ [PBfXwWeZMMs].webm
Tus\ -\ Όσα\ δε\ σου\ 'χα\ πει\ Prod.\ John\ Thanos\ -\ Official\ Audio\ Release\ [BPn8Ec-V2sE].webm
TUS\ -\ Όσο\ μ'\ αρέσει\ (2000)\ |\ TUS\ -\ Oso\ m\ aresei\ (2000)\ [0Rk0s_lm400].webm
Tus\ -\ Ούτε\ Για\ Ζήτω\ |\ Oute\ Gia\ Zito\ -\ Official\ Video\ Clip\ [5O26LLx8P2M].webm
Tus\ -\ Πεθαίνουν\ Για\ Μένα\ Prod.\ Dennis\ Cage\ -\ Official\ Audio\ Release\ [RXcHhAStC9E].webm
Tus\ -\ Πεθαίνουν\ Για\ Μένα\ Prod.\ Dennis\ Cage\ -\ Official\ Video\ Clip\ [FGMXALlsxw8].webm
Tus\ -\ Πιτσιρικάκι\ Remix\ prod.\ Άρχοντας\ [sKykzuIesio].mp4
Tus\ -\ Πιτσιρικάκι\ Remix\ prod.\ Άρχοντας\ [sKykzuIesio].webm
Tus\ -\ Που\ είναι\ τα\ λεφτά\ |\ Tus\ -\ Pou\ einai\ ta\ lefta\ -\ Official\ Video\ Clip\ [-FO3JcGRrfY].webm
Tus\ -\ Πρώτος\ Στα\ Trends\ Prod.\ Jumper\ -\ Official\ Video\ Clip\ [QOEGjsuchJk].webm
TUS\ -\ Πρώτος\ στο\ σχολείο\ -\ Music\ Μαρία\ Γιαννίκου\ Prod.\ Stoic-\ Official\ Video\ Clip\ [OcArxVsbsP0].webm
Tus\ -\ Πως\ Tus\ Prod.\ Dennis\ Cage\ [umYraDKf7zs].webm
Tus\ -\ Ραπ\ εμπορικό\ κάλαντο\ [wqTZfqzRiqg].webm
Tus\ -\ Ρε\ Μανα\ prod.\ Jusa\ Riddim\ (#onetake\ video)\ [9TnNqO6ejo8].webm
Tus\ -\ Ρούφα\ το\ τρομπόνι\ Prod.\ Fus\ Guest\ Star\ Emilia\ Barak\ -\ Official\ Video\ Clip\ [pIa1BcHROW0].webm
Tus\ &\ Σάκης\ Βέρρος\ -\ Μόνη\ -\ Prod\ Fus\ -\ Official\ Video\ Clip\ [jarzXp8PG9I].webm
Tus\ -\ Σάττι\ Μαρίνα\ |\ Tus\ -\ Satti\ Marina\ \ -\ Official\ Audio\ Release\ [lko2Hbph4z4].webm
TUS\ -\ Σε\ θέλω\ (2000)\ |\ TUS\ -\ Se\ thelo\ (2000)\ [iTHQkjMO3x4].webm
Tus\ &\ Σεξπυρ\ -\ Μουνάρα\ μεν\ αλλά\ πουτάνα\ |\ Tus\ &\ Sexpyr\ -\ Mounara\ Men\ Alla\ Poutana\ [I0zsTpXlhoI].webm
Tus\ &\ Σεξπυρ\ -\ Περνάω\ μηνύματα\ |\ Tus\ &\ Sexpyr\ -\ Pernaw\ minimata\ [hDUJpHYVy5A].webm
Tus\ -\ Σουβλάκι\ Κλαρίνο\ &\ Freddo\ Cappuccino\ Prod.\ John\ Thanos\ -\ Official\ Video\ Clip\ [wvGOtnKMmD8].webm
Tus\ -\ στο\ STAR\ κουτσομπολιό\ να\ γίνεται\ [-YmSmDc8Rjw].webm
Tus\ στο\ Your\ Face\ Sounds\ familiar\ by\ Ματθίλδη\ Μαγγίρα\ [6omhM-paNtk].webm
Tus\ -\ Στοματικό\ στον\ Νικόλα\ -\ live\ στο\ Μαρούσι\ |\ Tus\ -\ Stomatiko\ Ston\ Nikola\ -\ Live\ Sto\ Marousi\ [u5FzJLtr92M].webm
TUS\ -\ Συνέντευξη\ στο\ Mad\ Day\ Live\ |\ TUS-\ Interview\ at\ Mad\ Day\ Live\ [PGHPcwNobLM].webm
TUS\ -\ Σχετικά\ με\ το\ τραγούδι\ βουλγάρες\ [Zc7m-kwSAok].webm
Tus\ -\ Σώτης\ Βολάνης\ -\ Άραβας\ θέλω\ να\ γίνω\ (Fus\ RmX)\ -\ Lyric\ Video\ [t76ncm-XzYU].webm
Tus\ -\ Τα\ Nike\ Prod.\ Minelli\ -\ Official\ Video\ Clip\ [_-MonH-qfBs].webm
Tus\ -\ Τα\ κακά\ κορίτσια\ (prod.\ John\ Thanos)\ -\ Official\ Audio\ Release\ [_ShvOJ4n78I].webm
Tus\ -\ Τάμα\ ft\ \ Γωγώ\ Τσαμπά\ -\ Official\ Audio\ Release\ [jj0ETUs5ykQ].webm
Tus\ -\ Τα\ Παιδιά\ Στη\ Γειτονιά\ prod.\ Dennis\ Cage\ |\ Official\ Video\ Clip\ [8bpiW3r3Na0].webm
Tus\ -\ Τα\ Φυτά\ Prod.\ Fus\ -\ Official\ Video\ Clip\ [1Jk03sTptsk].webm
Tus\ -\ Τελευταία\ Φορά\ Prod.\ Strazdine\ -\ Official\ Video\ Clip\ [xoaA673qYzk].webm
Tus\ -\ Τι\ Θέλεις\ Να\ Κάνω\ Prod.\ Minelli\ -\ Official\ Video\ Clip\ [wdrZileylN8].webm
TUS\ -\ \ 'Το\ αντίθετο\ ακριβώς'\ -\ Mad\ Day\ Live\ [KPuojlPOVYw].webm
TUS\ -\ \ "Το\ αντίθετο\ ακριβώς"\ -\ Mad\ Day\ Live\ [KPuojlPOVYw].webm
Tus\ -\ Το\ Καπέλο\ Μου\ |\ To\ Kapelo\ Mou\ -\ Official\ Lyric\ Video\ [iWpBXwGGTbU].webm
TUS\ -\ ΤΟ\ ΚΟΥΜΠΙ\ PROD\ STOIC\ \ |\ \ TUS\ -\ TO\ KOUMPI\ PROD.\ STOIC\ [KGLm0JcARvM].webm
Tus\ -\ Το\ μνι\ -\ Live\ στο\ Γκάζι\ [SHn8lIv0d44].webm
TUS\ -\ Το\ ταξίδι\ που\ διάλεξες\ (2000)\ |\ TUS\ -\ To\ taksidi\ pou\ dialekses\ (2000)\ [ts-SEBjjRuA].webm
Tus\ -\ Το\ Χαπάκι\ ft\ \ Λευτέρης\ Βαζαίος\ -\ Official\ Audio\ Release\ [aElkC3VpsfE].webm
Tus\ -\ Τραγικό\ Φινάλε\ (Bάλε,\ Βάλε)\ -\ Official\ Audio\ Release\ [vgEVVKzbAdY].webm
Tus\ -\ Τσι\ -\ γκάνι\ Prod.\ John\ Thanos\ -\ Official\ Audio\ Release\ [XPRq7sMrBco].webm
Tus\ -\ Τσι\ -\ γκάνι\ Prod.\ John\ Thanos\ -\ Official\ Video\ Clip\ [K5bU4Vzbfps].webm
Tus\ -\ Τσίπρας\ Αλέξης\ |\ Tsipras\ Alexis\ -\ Official\ Audio\ Release\ [EKYEDxTzhr8].webm
Tus\ &\ Ύποπτος\ &\ Άρχοντας\ -\ Είμαι\ Χαρμάνης\ -\ Official\ Audio\ Release\ [JuoheCbO2DI].webm
Tus\ -\ Υστεροφημία\ Prod.\ Dennis\ Cage\ [HCJPuUfiH-M].webm
Tus\ -\ Φάντασμα\ ft\ \ Μαρία\ Γιαννίκου\ -\ Official\ Audio\ Release\ [d_pIsZKakgY].webm
Tus\ -\ Φιδίσιο\ Freestyle\ |\ Tus\ Fidisio\ Freestyle\ [J2rR7NVMppc].mp4
Tus\ -\ Φιλάκια\ -\ Official\ Audio\ Release\ [9oWXk788-i4].webm
TUS\ -\ (Φώτης\ και\ Μαρία\ Live)\ STAR\ CHANNEL\ 'www.facebook.com_tus.h.tusis'\ [j8evM82JQTk].webm
TUS\ -\ (Φώτης\ και\ Μαρία\ Live)\ STAR\ CHANNEL\ "www.facebook.com⧸tus.h.tusis"\ [j8evM82JQTk].webm
Tus\ &\ Χαρά\ Βέρρα\ -\ Μαργαρίτες\ (Fus\ RMX)\ |\ Tus\ &\ Xara\ Verra\ -\ Margarites\ \ (Fus\ RMX)\ [ZbJ9y_g1Gug].webm
Tus\ -\ Χειροβομβίδα\ ft\ Πωλίνα\ -\ Official\ Audio\ Release\ [5cUpE4e1thw].webm
Tus\ -\ χόρτο\ ρε\ βλάκα\ |\ Tus\ -\ xorto\ re\ vlaka\ [7eAt1LR8oCc].webm
Tus\ -\ Ψυχανάλυση\ Prod.\ Dennis\ Cage\ [qF31-0C7Now].webm
Tus\ -\ Деньги\ да\ Prod\ Slavic\ Boys\ TM\ -\ Official\ Video\ Clip\ [kZHk7jzcv3U].webm
Tus\ -\ 母親\ -\ Prod.\ Dennis\ Cage\ -\ Official\ Video\ Clip\ [9aKmlSYjSvo].webm
Vibrator\ |\ Son\ Of\ The\ Beats\ [2fUf-DA6Tlk].webm
ΑΚ-47\ -\ 'Αλφα\ Κάππα\ (Tus,\ Αρχο)\ |\ AK-47\ -\ Alfa\ Kappa\ (Tus,\ Arxo)\ -\ Official\ Audio\ Release\ [6H-WVcGrJTA].webm
ΑΚ-47\ -\ \ Η\ καλύτερη\ μέρα\ για\ να\ πεθάνεις\ (Tus,\ Άρχο)\ -\ Official\ Audio\ Release\ [84-6QG-wtOg].webm
ΑΚ-47\ -\ Κιλά\ (Tus,\ Αρχο)\ |\ AK-47\ -\ Kila\ (Tus,\ Arxo)\ -\ Official\ Audio\ Release\ [EaEBPI0Jglo].webm
ΑΚ-47\ -\ Κομμάτια\ (Tus,\ Άρχο)\ -\ Official\ Audio\ Release\ [LM_ktSiwmS4].webm
ΑΚ-47\ -\ Πάνω\ Στο\ Κ*υλί\ (Tus,\ Αρχο)\ |\ AK-47\ -\ Pano\ Sto\ K*vli\ (Tus,\ Arxo)\ -\ Official\ Audio\ Release\ [guhXF56CZGs].webm
ΑΚ-47\ -\ Πέρα\ στους\ πέρα\ κάμπους\ (Tus,\ Άρχο)\ -\ Official\ Audio\ Release\ [vsIo39dXAUA].webm
ΑΚ-47\ -\ Στον\ Πυθμένα\ (Tus,\ Άρχο)\ -\ Official\ Audio\ Release\ [UjE5oc_togg].webm
ΑΚ-47\ -\ Το\ κρίμα\ στον\ λαιμό\ σου\ (Tus,\ Άρχο)\ -\ Official\ Audio\ Release\ [_IULOiX9uDw].webm
Αντώνης\ Γαμπιεράκης\ -\ Είτε\ τότε\ είτε\ τώρα\ ft\ Ματθαίος\ Γιαννούλης\ &\ Tus\ -\ Prod\ Fus\ -\ Video\ Clip\ [YmhR82DYeeE].webm
Γιάννης\ Μαυρίδης\ ft.\ TUS\ -\ Θεσσαλονίκη\ -\ Official\ Video\ Clip\ [e6D6P277LSc].webm
Γιάννης\ Μαυρίδης\ &\ Tus\ -\ Πόσο\ του\ μηνός\ -\ Official\ Audio\ Release\ [Z7Yw_AsE2uA].webm
Γιώργος\ Λιάτης\ ft.\ Tus\ -\ Η\ πιο\ ωραία\ στην\ Ευρώπη\ I\ Giorgos\ Liatis\ ft.\ Tus\ -\ I\ pio\ oraia\ stin\ evropi\ [fAOoqtWiMWc].webm
Η\ Tus\ ή\ Tusis\ Productions\ σας\ εύχεται\ καλές\ γιορτές.\ [i2Bfb6g_huI].webm
Λευτέρης\ Πανταζής\ feat.\ Tus\ -\ Έρωτας\ |\ Lefteris\ Pantazis\ feat.\ Tus\ -\ Erotas\ [L7tcmHQveBY].webm
Λευτέρης\ Πανταζής\ feat.\ Tus\ -\ Έρωτας\ |\ Lefteris\ Pantazis\ feat.\ Tus\ -\ Erotas\ [P9aOpLZAMyA].webm
Νάντια\ Αγγελέτου\ ft.\ TUS\ -\ Έτσι\ γουστάρω\ -\ Official\ Video\ Clip\ [Wb-NX1HL9QE].webm
Νέο\ Video\ Clip\ έρχεται\ στις\ 08_11_2013\ [JcGjTbAuPc4].webm
Νέο\ Video\ Clip\ έρχεται\ στις\ 08⧸11⧸2013\ [JcGjTbAuPc4].webm
Νέος\ TUS\ έρχεται\ στις\ 20_10_2013\ [LS19odeY1Do].mkv
Νέος\ TUS\ έρχεται\ στις\ 20⧸10⧸2013\ [LS19odeY1Do].mp4
ΠΡΩΤΟΣ\ ΣΤΟ\ ΣΧΟΛΕΙΟ\ ΕΡΧΕΤΑΙ\ 11-9-2014\ [rGree3k0NJ8].webm
Σώτης\ Βολάνης\ &\ Tus\ -\ Δε\ Με\ Αγαπάει\ -\ Official\ Audio\ Release\ [epF3uIc-E0g].webm
Τus\ &\ Cenobite\ -\ an\ me\ krazeis\ piso\ apo\ to\ pc\ sou\ [NA5VhF1ilBc].webm
Τουσοντίνος\ (TusonaS)\ -\ Η\ Πιο\ Λιώμα\ Στην\ Ελλάδα\ |\ Official\ Video\ Clip\ 2015\ [XOpFJMsKuA4].mkv
Χάρης\ Ακριτίδης\ Feat\ \ TUS\ –\ Ψυχοθεραπεία\ [NhjU3ROHyCc].webm
Χάρης\ Ακριτίδης\ Feat\ TUS\ –\ Ψυχοθεραπεία\ \ -\ Official\ Video\ Clip\ [ky3QOkinD4k].webm
Score:1
cn flag

No need for grep (but would work if you add the -z switch):

find -type f -name '*|*' -exec cp {} ident/ \;
Estatistics avatar
cn flag
thanks! worked like a charm! can you explain why "\"?
cn flag
@Estatistics: it escapes the semi-colon, i.e. the terminator for the `-exec` parameter. From the findutils.info manual: `-exec command ;`. Because the semi-colon is also a command separator in most shells, it needs to be escaped with a backslash.
cn flag
@Estatistics: You can find the section of the manual with this command: `info find 'actions' 'run commands' 'single file'`.
Score:0
br flag

the -i option is missing at the xargs command (see man xargs).

find . -type f -print0 | grep -i "|" | xargs -i -0 cp {} ident/

I an not sure what you try to do with the grep

without the grep it would be just the find:

find . -type f -exec cp -v {} ident/ \;

or if I interpret the grep correct it might be this:

find . -type f -iname '*|*' -exec cp -v {} ident/ \;

see man find

Estatistics avatar
cn flag
1st says binary file matches. do nothing. 2nd/3rd says find: argument to '-exec' is missing. thanks anyway
Marco avatar
br flag
Sorry, I forgot the "\;" at the end of find. The message "binary file matches" comes from the "grep" which I copied from your question and you did not explain the reason for the grep in your question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.