You are not logged in.

#1 27 Mar 2014 03:32

Lauraq
Member
Registered: 31 Jul 2011
Posts: 34

.bat (thank's to the creator bluesxman) problem special caracters

Some time ago I asked for help to create a bat that I were going to copy the mp3 from a list (this is the link to the discussion http://ss64.org/viewtopic.php?id=1298&p=1)
I was helped by many people and, in the end, I had used. the .bat created by bluesxman.
Only now I realized that it does not work with accented characters (such as "is" or "ù")
Can someone correct the bat? Thank you!

This is the bat:

@echo off

mode con codepage select=1252
set root=F:\ITA\
set list=E:\list ITA.txt
set another_folder=F:\Playlist ITA
set "all_files=%temp%\%~n0.all"

REM create a list of all mp3 files at source
echo:Scanning all files...
type nul > "%all_files%"
for /f "usebackq tokens=*" %%a in (`dir /a:-d /b /s "%root%\*.mp3"`) do echo:"%%~a"^|"|%%~na|" >> "%all_files%"

REM reprocess the search term list file into a format I can use
type nul > "%list%.fixed"
for /f "usebackq tokens=*" %%a in ("%list%") do (
    set /p "out=|%%a|" <nul & echo:
    set /p "out=|[0-9][0-9] - %%a|" <nul & echo:
) >> "%list%.fixed"

REM for every item in the search term list, filter matching lines from the list of all files
REM and copy the file to the target (I'm assuming you want a flat directory structure here)
echo:Filtering required files...
for /f "usebackq delims=| tokens=1*" %%a in (`type "%all_files%" ^| findstr /r /i /g:"%list%.fixed"`) do (
    echo:"%%~a"
    mkdir "%another_folder%%%~pa" 2>nul
    copy /y "%%~a" "%another_folder%%%~pa"
)

pause

or, if is to hard, if there is an utility that can search files from a txt list

Thanks!

Last edited by Lauraq (27 Mar 2014 03:34)

Offline

#2 27 Mar 2014 06:55

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: .bat (thank's to the creator bluesxman) problem special caracters

findstr and find will both search for text in a file.

findrepl.bat is a grep-like tool that has a good feature set - download from:  https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat

Place `findrepl.bat` in the same folder as the text file or on the path.


Someone else with experience will comment on the non-latin characters, as they can be problematic.

Offline

#3 27 Mar 2014 09:25

Lauraq
Member
Registered: 31 Jul 2011
Posts: 34

Re: .bat (thank's to the creator bluesxman) problem special caracters

I did not understand anything of what I should do with the file that you have posted smile
I hope and believe that there is someone who has a simple solution becouse I m not expert sad

Last edited by Lauraq (27 Mar 2014 09:25)

Offline

#4 27 Mar 2014 09:36

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: .bat (thank's to the creator bluesxman) problem special caracters

People reading your question need details about what you plan to do before they can provide detailed code.

Offline

#5 27 Mar 2014 09:57

Lauraq
Member
Registered: 31 Jul 2011
Posts: 34

Re: .bat (thank's to the creator bluesxman) problem special caracters

sorry but what details? I linked the thread that I had opened and the question is always the same, a bat that copy mp3 from a txt list. The .bat that I posted works perfectly except for accented characters that are not copied

Offline

#6 27 Mar 2014 10:24

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: .bat (thank's to the creator bluesxman) problem special caracters

You also asked to search a file and I posted info on three utilities that will do that. 

Good luck.

Offline

#7 27 Mar 2014 11:21

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: .bat (thank's to the creator bluesxman) problem special caracters

Wow that was a while ago; glad my script was helpful.  I don't have too much experience with non-Latin character sets, hopefully one of our more worldly contributors can offer a robust solution.

For the moment, you could try working around the issue by replacing non-Latin characters in your search terms text file with a ".", such that this:

this is jùst an example

becomes:

this is j.st an example

NB -- The dot character will match any character in that position, so with shorter search terms there is a small chance you will match more files than you intended.

Last edited by bluesxman (27 Mar 2014 11:21)


cmd | *sh | ruby | chef

Offline

#8 27 Mar 2014 12:24

Lauraq
Member
Registered: 31 Jul 2011
Posts: 34

Re: .bat (thank's to the creator bluesxman) problem special caracters

I am happy to resent and hate you for the ease with which you can find solutions ^_^
Your idea works great, I get some duplicates but it is already a huge improvement! Then if anyone knows how to permanently solve the problem, I'm here waiting

Offline

#9 27 Mar 2014 14:36

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: .bat (thank's to the creator bluesxman) problem special caracters

wink


cmd | *sh | ruby | chef

Offline

Board footer

Powered by