Jump to content

DosCode

Member
  • Posts

    46
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Czech Republic

Everything posted by DosCode

  1. The pdf filename number #1 means chapter. There are about 6 chapters in this case, no more. So we speak about 1 digit on begin of file, which defines what html file I will process. So if I have the digit I know in which file I will look for information. In the case of first chapter, the name of html file is "GEN 0 GENERAL.html". There are next 5 files, the naming convention is: "GEN " + digit + " " PS: I already know where I have a error so I try no to finish this
  2. Well, I study the manual since night and I read "all" about SET and variables, but I can't find some things. I read that the exclamation mark is used by system variables something related to "expanding" of variable (my CMD is not in English, so I try to translate back). But did not find how to connect/join the two types of variables with strings. There are readings and examples about searching of substrings and replacing if them. So can you link me where I can find it? So there is variable @something@ to join with "somethingelse" or to join with @somethingelse@ and there should be variable !something! to join with "somethingelse" or to join with !somethingelse! ... or maybe with @something@ ....
  3. I try according 5eraph's code to make my own try. But I have some problem that it does not do what I would expected. I will do it in two steps so this is just step one, on which I want to try how to work with variables when I try to rename file. I have files with filenames started by number 0 to 9... I want to get the number to variable. First file is 0_1_en.pdf, so I would like to get 0 to sPDFName. SETLOCAL EnableDelayedExpansion for /f "delims=" %%PDF in ('dir /b *.pdf') do ( SET "sPDFName=%%~nxPDF" echo "!sPDFName:~0,1!" IF "!sPDFName:~0,1!"=="1" (SET "sPDFName=!sPDFName:~0,1!") IF "!sPDFName:~0,1!"=="0" (SET "sPDFName=!sPDFName:~0,1!") echo "!sPDFName:~-0!" echo "%sPDFName%" pause for /f "delims=" %%HTML in ('dir /b *.html') do ( :: compare "GEN "+sPDFName+" " to be equal to "!%%HTML:~0,6!" IF "!sPDFName:~-0!"=="!%%HTML:~0,6!" echo %%HTML ) ) I display the variable sPDFName by echo "!sPDFName:~-0!" which probably is not the best way. How to display the sPDFName's variable value, %sPDFName% shows nothing? And I need to compare this: "GEN "+"sPDFName+" " should be equal to "!%%HTML:~0,6!" so if the pdf file has 0 the file "GEN 0 GENERAL.html" will be used in next process. But don't know how can I connect these 3 parts together on left side of expression.
  4. Does the number "4" at last line mean how the search string is long? I mean gen_ has 4 letters
  5. Right now this happened to me with these files: gen_0_3.pdf gen_2_1.pdf gen_4_1.pdf gen_4_2.pdf so the FOR /F "TOKENS=*" %%# IN ('DIR/B/S/A-D "gen_*.pdf"') DO CALL :RN "%%#" "%%~nx#" GOTO :BREAK :RN SET "_FN=%~2" ::ECHO= REN %1 "%_FN:~7%" :BREAK causes they are renamed to .pdf .pdf .pdf .pdf
  6. I found the dependencies later.
  7. Thanks. I didn't like sed because it seemed too hard to understand it, but this example with regex looks really simple and understandable.
  8. Sure but this is not batch script, this is directy in CMD, so this %a is correct.
  9. I installed wingnu32 and perl and I try to run such command that should get Title from tags <title>Title</title> I am not sure, is it possible to run this program in cmd? Maybe I have wrong quoting? I tried few things 1. for /f "delims=" %a in ('dir /b *.a') do ( pcretest.exe -nle 'print $& if /(?<=title>).*(?=<\/title)/' < %a ) 2. for /f "delims=" %a in ('dir /b *.a') do ( pcretest.exe -ln0e '$,="\n";print /(?<=<title>).*?(?=<\/title)/sg' < %a ) 3. for /f "delims=" %a in ('dir /b *.a') do ( %a | pcretest.exe -nle 'print $& if /(?<=title>).*(?=<\/title)/' ) but I am getting error like: > not expected here...
  10. Hello, I downloaded egrep from gnuwin32 grep 2.5.4 package and the program requires pcre3.dll. I have Win XP SP3 but no pcre3.dll. I searched internet for this file, but dont know where to get it (some secure place).
  11. Can you explain me what does the command DIR /B /AD "!sPDFName:~0,4!"? I see it first time with dir command - it looks like you used regular expression, but I am not able to reproduce it in command line separately. Even in batch when I write echo %sPDFName% so it prints some regular expression or what is it not, the value(?) (I thought it should keep value like four letter of the filename).
  12. Thank you and I start with 5eraph's code. This is output. MOVE "EKYT DME 08L_en.pdf" "EKYT\" MD "EKYT" MOVE "EKYT en.pdf" "EKYT\" MD "EKYT" MOVE "EKYT ILS_DME 08L_en.pdf" "EKYT\" MD "EKYT" MOVE "EKYT ILS_DME 26R (CAT I_II)_en.pdf" "EKYT\" MD "EKYT" MOVE "EKYT PDC_en.pdf" "EKYT\" MD "EKYT" MOVE "EKYT VOR_DME 26R_en.pdf" "EKYT\" Press any key to continue... It looks that everything should work, no error. But I can't find my folders. Edit: I think it is related to the command: ECHO=MD "!sPDFName:~0,4!" When I remove ECHO= so the command works. But no display of process. Thank you, you saved me a lot of work.
  13. I have just downloaded these files and would like to make directories to them. I will shorten the list of files coz it is really long. EKAH-ADC_en.pdf EKAH-APDC_en.pdf EKAH_en.pdf EKAH_PATC.pdf EKBI-ADC_en.pdf EKBI-APDC_en.pdf EKBI-ILS-09-(CAT I_II_III)-(ACFT CAT A_B)_en.pdf EKBI-SID-09-1_en.pdf EKBI_en.pdf EKCH-AOC-A 04L_en.pdf EKCH-AOC-A 30_en.pdf EKCH-APDC SOUTH_en.pdf EKCH-GMC-4_en.pdf EKCH-STANDARD TAXI ROUTES-22L_en.pdf EKCH_ADC_en.pdf EKCH_PATC_22L.pdf EKCH_STANDARD-TAXI-ROUTES-04L_en.pdf EKEB-ADC_en.pdf EKEB-NDB 26 (ACFT CAT B)_en.pdf EKEB_en.pdf EKEB_ILS_DME_26_ES_A_en.pdf EKEB_PATC_26.pdf EKHG-ADC_en.pdf EKHG-SRE-27_en.pdf EKHG_en.pdf EKKA-ADC_en.pdf EKYT ADC_en.pdf EKYT ATC-26R_en.pdf EKYT DME 08L_en.pdf EKYT en.pdf But the name could be also for example: _EKAH-ADC_en.pdf The new directory should be called from the 4 characters at begin of filename. So EKAH-ADC_en.pdf needs EKAH directory and move it there. Could you please help me to do this script?
  14. The pause is good. I will use the script more times, so to be sure the path is OK. Note: The script sometimes leave extra _ in begin of filename and sometimes it removes one more letter (that should not be deleted) from begin of string. The second problem is not often, so not much problem. I don't want to bother you with it. But I have one more question I need to ask, in different thread.
  15. Thanks. The last line was not working for me. Nothing happened. But when I removed the "ECHO=" files are renamed correctly.
  16. Yes I want to remove it. I originally didn't find how to do it, so I tried to replace it for "_" but the best solution would be to remove it.
  17. List of files C:\program files\GnuWin32\bin\wget.exe C:\program files\GnuWin32\bin\www.slv.dk C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-10698 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-11344 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-11345 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-11346 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1402 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1403 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1404 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1405 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1406 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1407 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1408 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1409 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1410 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1411 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1412 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1413 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1414 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1415 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1416 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1417 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1421 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1422 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1423 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1424 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1426 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1427 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1428 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1429 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1430 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1431 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1432 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1433 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1434 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1435 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1436 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1437 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-6463 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-6464 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-8808 C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-10698\_K_ENR_3_6_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-11344\_K_ENR_6_LAS_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-11345\_K_ENR_6_UAS_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-11346\_K_ENR_6_HMR_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1402\_K_ENR_0_6_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1403\_K_ENR_1_1_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1404\ENR_1_10_amdt_7_2004_8JUL.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1405\_K_ENR_1_11_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1406\enr_1_12.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1407\_K_ENR_1_13_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1408\_K_ENR_1_14_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1409\_K_ENR_1_2_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1410\enr_1_3.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1411\enr_1_4.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1412\ENR_1_5_AMDT_2_2004_19FEB.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1413\_K_ENR_1_6_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1414\enr_1_7.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1415\_K_ENR_1_8_en_02_07_AIRAC.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1416\_K_ENR_1_9_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1417\_K_ENR_2_1_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1421\_K_ENR_3_3_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1422\_K_ENR_3_4_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1423\_K_ENR_3_5_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1424\_K_ENR_4_1_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1426\enr_4_2.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1427\_K_ENR_4_3_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1428\_K_ENR_4_4_en_10_07.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1429\_K_ENR_5_1_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1430\_K_ENR_5_2_en_03_07_pdf.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1431\_K_ENR_5_3_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1432\_K_ENR_5_4_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1433\_K_ENR_5_5_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1434\enr_5_6.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1435\_K_ENR_6_1_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1436\enr62-1.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-1437\enr62-3.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-6463\_K_ENR_3_1_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-6464\_K_ENR_3_2_en.pdf C:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-8808\_K_ENR_2_2_en.pdf There are files like _K_ENR_1_6_en.pdf where I want to remove the _K_ENR_ sting from name of file. Thanks.
  18. It doesn't work for me. It looks that the last part of command rename _K_ENR_*.PDF" "_*.pdf" doesn't work. Four last lines from the screen output: c:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get>REN "c:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-6464\_K_ENR_*.PDF" "_*.pdf" c:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get>REN "c:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get\Document-8808\_K_ENR_*.PDF" "_*.pdf" c:\program files\GnuWin32\bin\www.slv.dk\Dokumenter\dsweb\Get>IF T == T POPD c:\program files\GnuWin32\bin>PAUSE Press any key to continue...
  19. But this is more hard to remmeber. The command before is very simple. Can I ask you what does mean "%_P%" "%CD%" PUSHD SET "_=T" FOR /D T POPD ?
  20. Oops. Thanx for help. It works. I got the command that I needed to rename my files. @Echo off cls echo on for /r ".\www.slv.dk\Dokumenter\dsweb\Get" %%x in (.) do rename %%x\BG_AD_3_BG*.pdf _*.pdf & pause pause I originally wanted to rename *.pdf files and remove the BG_AD_3_BG string from begin of the name.
  21. Hello, I try to be as sort as possible. I try to do some code in batch and cmd.exe (running Windows). Nwo I try the basic: I try to echo subdirectories listed in a folder. for /r %%x in (.\www.slv.dk\Dokumenter\dsweb\Get) do echo "%%x\" This should list the directories in Get folder. I know there is a bug, because I got this list of files as output: C:/program files/GnuWin32/bin/./www.slv.dk/Dokumenter/dsweb/Get/ C:/program files/GnuWin32/bin/www.slv.dk/./www.slv.dk/Dokumenter/dsweb/Get/ C:/program files/GnuWin32/bin/www.slv.dk/Dokumenter/./www.slv.dk/Dokumenter/dsweb/Get/ Once again: C:/program files/GnuWin32/bin/./www.slv.dk/Dokumenter/dsweb/Get/ C:/program files/GnuWin32/bin/www.slv.dk/./www.slv.dk/Dokumenter/dsweb/Get/ C:/program files/GnuWin32/bin/www.slv.dk/Dokumenter/./www.slv.dk/Dokumenter/dsweb/Get/ The marked text is incorrect / non-existing path. It means there is added "./www.slv.dk/Dokumenter/dsweb/Get/" on end of %%x variable. But I don't understand why there is listed: C:/program files/GnuWin32/bin/www.slv.dk/ and C:/program files/GnuWin32/bin/www.slv.dk/Dokumenter/ instead of the /Get directory??? I would expect something like this: C:/program files/GnuWin32/bin/./www.slv.dk/Dokumenter/dsweb/Get/Document-900 C:/program files/GnuWin32/bin/./www.slv.dk/Dokumenter/dsweb/Get/Document-901 C:/program files/GnuWin32/bin/./www.slv.dk/Dokumenter/dsweb/Get/Document-902 etc Is there any simple solution how to make the for echo correct folders? The echo command is just 1st step; I would change it later to this command rename %%x\BG_AD_3_BG*.pdf _*.pdf
×
×
  • Create New...