Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


DosCode

Member
  • Content Count

    46
  • Donations

    $0.00 
  • Joined

  • Last visited

Community Reputation

0 Neutral

About DosCode

Profile Information

  • OS
    none specified
  1. bphlpt I need no reply for that pdf convertion. I already have my solution. "I still would be interested in seeing your COMPLETE solution, since you say you have one" I should repeat that I use more scripts, not one complete script. I download files from more pages and servers. Check the last post on page 2. The Poland page, this is the last task I did. Before, I did this page: My link and I included code to determine if the number has decimal. Because the search process could take too long if I have files like "ENR 1.72 ...", "ENR 1.7 ...", "ENR 10 ..." .... I search for "ENR "+digit+space... and that caused I would looked for more files then I want. I really don't know if to send here the script, that already serve to different purpose - goal has change a little bit for different task. "I'm always interested in learning new CMD script tricks and I've learned they can come from unlikely sources. So, will you share?" I think I could send you all my scripts on your email if you want. But they are really individual. I for example have wget script and I always rewrite the url address from where I download or I change the -A argument, according my conditions. The poland files I downloaded with downthemall - I had some problem, that the wget did not worked for this server. "Hopefully they at least say thanks, and most do." Man, If you would know me, you would know that I say always thanks in my life even if it is not necessary. "Apparently you are more interested in learning how rather than the speed of getting to the solution, and that is admirable." Yeah, my approch is different. I am used to when I learn something it consumes really huge quantums of time. Layout the complete task Provide the type of input data you will be dealing with Describe the output you wish - exactly - and sometimes even say why Describe the steps you want to learn how to do in order to get from input to output Describing things is something mystical for me. But I really sometimes am lost on this thread, because all the posts seems soooo long.
  2. Your answer shows you lie. I did my job what I needed. It does not mind that my code is not according your ideas. Please don't say I learned nothing or you are liar! I have many bad habits and in my country we say "You cannot learn an old dog dancing!".
  3. You are moderator, you know very well that I gave thank to all at 23 February 2012 - 05:24 PM! And "failure to listen, learn, understand" ... this is not my failure but natural part of my character, this is me. I confess, I have no problem with acceptation of my being!
  4. No, this Forums Members as good as wrote it for you but you don't need it, it serves no purpose. This newer single script negates its use!!! You are the only person running a script to change a file name before running another script to change the same file name, that can only be your fault. As the topic is titled, I was looking for CMD script. And in the time when I didn't find CMD solution here I was looking another way to get answer and to make my own script. This was before your solutions came here. I started to learn the CMD scripting as I have beed reffered to the links. So I don't know why you wonder what I rather decided to use my own script. It is still subject of my learning and I don't know what you don't understand when I say that I better like to do my own script to learn it ... than to use someone's code which is already done. Also somebody in this thread has written that THIS THREAD SERVES TO ALL. Then your assertion is not true, because other user's can use the different version of code (versions of other coders). Even me. I take this thread as a place of information where I can come back whenever. Whenever when I feel that I am stuck somewhere I can look how you did your code. So really don't understand where you see problem. Sorry for posting miss-clicking on incorrect button, so I posted the new question in the same thread.
  5. I tried to do some script to rename pdf files from this site: http://www.pl-vacc.org/pol3/files.php?d=maps&language=en @echo off setlocal EnableDelayedExpansion for %%P in (*.pdf) do ( set "pdfFile=%%P" set "htmlMask=info.htm" echo Testing "!pdfFile!": Looking in !htmlMask! for %%H in (!htmlMask!) do ( echo "%%H" set "pdf=%%P" set "source=%%H" call :JUMP ) ) ) ) :JUMP REM Get title for pdf from html file rem Process each line in %source% file: for /F "delims=" %%c in ('find /N "%pdf%" "%source%"') do ( set "line=%%c" REM Test if the line contains pdf file I look for: SET "pdfline=!line:%pdf%=!" if not "!pdfline!" == "!line!" ( cls SET "pdfline=!pdfline: = !" SET "pdfline=!pdfline:</a>= !" SET "pdfline=!pdfline:*>=!" SET "pdfline=!pdfline:*>=!" SET "pdfline=!pdfline:*>=!" SET "pdfline=!pdfline:*>=!" SET "title=!pdfline:*>=!" set "title=!title::=-!" set "title=!title:\=-!" set "title=!title:/=-!" set "title=!title:|=-!" set "title=!title:?=-!" set "title=!title:^==-!" set "title=!title:>=-!" set "title=!title:<=-!" ren "%%P" "!title!.pdf" ) ) This action was fast.
  6. I've written that already, but I will recall it to you. It is not a fault! I decided to rename the files (to remove prefix) before I have decided to write script that renames the files according html description.
  7. I just click it. It is more faster. I sometimes run cmd to console but there happens to me I forget to close it so I have 4 or 5 cmd consoles, so more windows opened makes it confusing to orientate so I like it to autoclose. I usually add a pause, but I it could be so that you could use in the code somewhere command to go to end of file. So I did not add it there. You seen that I used pause everywhere. Also I edited the previous post to you, also bad habit.
  8. This is my final solution. It takes cca 20 seconds to rename the files, maybe some of the solutions here mentioned by others could be faster. But I am satisfied, that it works. @echo off setlocal EnableDelayedExpansion for %%P in (*.pdf) do ( set "pdfFile=%%P" set htmlMask="GEN !pdfFile:~0,1! *.html" REM echo !htmlMask! echo Testing "!pdfFile!": Looking for !htmlMask! for %%H in (!htmlMask!) do ( echo "%%H" set "pdf=%%P" set "source=%%H" call :JUMP ) ) ) :JUMP REM Get title for pdf from html file rem Process each line in %source% file: for /F "usebackq delims=" %%c in ("%source%") do ( set "line=%%c" REM Test if the line contains pdf file I look for: SET "pdfline=!line:%pdf%=!" if not "!pdfline!" == "!line!" ( REM Test if the pdfline contains tag b if not "!pdfline:*><b>=!" == "!pdfline!" ( cls set "tag=!pdfline:<b>=$!" set "tag=!tag:</b>=$!" for /F "tokens=2 delims=$" %%b in ("!tag!") do set title=%%b set "title=!title::=-!" set "title=!title:\=-!" set "title=!title:/=-!" set "title=!title:|=-!" set "title=!title:?=-!" set "title=!title:GEN =!" echo Title found: "!title!" ren "%%P" "!title!.pdf" ) ) ) Finally I decided to remove the "GEN " prefix in title. Edit: I've made some edit of the code, because I found some lines that was unneccesary, but did not test it. I tested the code before and it was really not good, so I made some changes in the code in my PC, but do not give it here, because the circumstances has changed.
  9. Well, then you know better what it does than me and I need not to tell you anything. I checked the code at the start and thought the loop looks for pdfs in html. That's why I asked you if my assumption is right, but you did not answer that question. And I run your code, but the console closed so I see no output. Then if you understand what I wanted to reach, I need not to tell you anything. jaclaz, isn't that what you wanted to hear? I thought your solution simple doesn't work. You don't understand my habits. I usually give thanx when I found some solution for my problem or when I finish my discussion in the thread. So that you don't receive thank doesn't mean you wouldn't receive it later.
  10. This is a sub-function. This tells me that you did not set %pdf% file to search for (in the html file). What do you try to do in the loop? Do you try to find all pfds that are in html document? Because what I tried to do was to find one certain pdf, that is in the html document. You can start either by searching pdfs, so you should set the name of pdf file. This instructs where the anchor and title is placed. But as a complete code, that should find all pdfs and for each pdf to open the html document which is associated with the pdf. So if your code as sub-function should work fine, you must define pdf file you look for. Late answer to bphlpt. „There are definitely cases, IMO, where CMD script is faster and more flexible than other options. “ That is not the reason why I’m interested in CMD. It is much simpler to me against VBS. VBS is Object orientated language and so is more harder to learn. CMD with connection with gnuwin results in something what seems to me similar to bash. So that is the reason for been it favourite for me. „CoffeeFiend and I don't need to continue on. “ I have finished so I also need not to continue. „Our two posts do not distract from your overall goal as much as your posts which have been scattered over multiple threads and have yet to come up with a working solution. “ So to you. You have seen I was distracted enough to overlooked two post. I explained that before. „You have been asking about bits and pieces for a week now, and we didn't even know what your overall goal was until 18 hours ago. “ If I would told you what was my overall goal, than I would spent a lot of time with long time explaining and I would not get answers to my original questions which were the individual solutions of certain situations. I did not want you just all solved instead me. The second point is that is was simpler to me just to make what I want by myself, and then to paste the code and wait your reactions. This is just the way of demonstration. That's better then lots of words. Since the start I see I have learned something, I moved from nothing to something. And that’s what I personally feel to be satisfying. Also I see no reason why I should spend 24 hours 7 days week on forum, I don't mind this took more then week. So maybe you had wait, but I see no problem in it. Late answer to Aacini's code Yes, works but there should be some condition, because it returns title "" and twice title ,,GEN 0.1 Preface", but you need not to do it, because I have already my code completed, so as you could see in the debuger's code version. Replay to Yzöwl's CMD code This script prints REN "gen_0_3.pdf" "GEN 0.3 Record of AIP Supplements.pdf" REN "gen_2_1.pdf" "GEN 2.1 Measuring System, Aircraft Markings, Holidays.pdf" REN "gen_4_1.pdf" "GEN 4.1 Charges for Aerodromes and Heliports.pdf" REN "gen_4_2.pdf" "GEN 4.2 Charges for Air Navigation Services.pdf" Press any key to continue... So pdfs staring by digit are not listed. Replay to CoffeeFiend I cursorily searched internet for gnuwin PowerShell binaries but did not find so did not test your code.
  11. I thank to all who have brought some solution and some code here. Sure. One day more of patience for today I hadn't time to devote to the code. bphlpt - yeah, it is the goal, to download files and rename them. But I personally more like individual scripts, every one servers to its own purpose. Because there are different situations, when I download different "folders" of pdf documents. So some files need to be moved, some need to be renamed, some need html documentation, some need no documentation. So this is something individual according what I download. I would be more glad if I would need not these scripts, but I don't know about such browser addon, that would enable you to download more levels of documents, create folders and move documents to folders according organization on html page, and rename folders by chapters or by their purpose and title in html page.
  12. jaclaz: Yes, I overlooked. Maybe because when I came to PC, I have seen the CoffeeFiend's reply about VBS and I did not read it, I just did not see there is one or two posts above it. Yours posts have been just between CoffeeFriend and bphlpt post about VBS, that I did not concentrated my attention to. The post are long on my screen taking much of place. Not simple to orientate. I guess the fault is on design of this site because the left column is too wide! I will try to have some time tomorrow. Now time to sleep.
×
×
  • Create New...