Content Type
Profiles
Forums
Events
Everything posted by Yzöwl
-
renaming files in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I haven't tested anyone else's code, I have no need to. I am prevented access to the site simply because I have a blocking application which does not like that site.However I've taken a look at the html code for GEN 0 GENERAL and it appears that your .pdf link lines look like this: If these are indeed the lines you are looking for then the following will always fail:findstr /C:"<a>" -
renaming files in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
It is not the solution! Unless the original remit has changed it is simply a sub function. BTW I'm unable to access the link to take a look at your .html, (I cannot access 'http://www.slv.dk/Dokumenter/' at all I receive Connection closed by remote server message). -
renaming files in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
The methods you are wanting to use are not really suitable for the task. You may be able to get your car up the street by pulling it with its built in winch but it's a darn site faster and more assured if you use its built in engine! -
Find printer registry [solved]
Yzöwl replied to JFMichaud's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
What you ended up doing was reversing the logic and the command thus achieving the same result. -
renaming files in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
TBH without all of the information and knowledge of which tools/language is used I couldn't say specifically which method I'd use either. I may be more inclined to use a directory structure to group linked files to their respective html rather than having them all in one location and order according to naming convention. It really is very dependant upon the specifics of their scenario. -
Find printer registry [solved]
Yzöwl replied to JFMichaud's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
You appear to have misunderstood the use of || and &&. What your script does is state that if the TOSHIBA search string is unsuccessful goto end of file whereas you wanted the reverse. Basically || means 'if the last command was unsuccessful' whereas && means 'if the last command succeeded'. Simply replacing || with && should prevent the continuation error. You actually made the same mistake in your opening script too and jaclaz added to the confusion by mimicking that in their example. In your working script the fourth line is completely redundant and can be removed. -
renaming files in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
You have not provided us with enough information to create your script. The key to your entire project appears to be the .html file, the way you have currently tried to break down the task into several topics places more emphasis on the .pdf files. My best understanding of what you want is to search each .html file in the local directory for a href containing a .pdf file name, (with a naming convention which can be likened to the source file name), and which is also local to the script. If true, you wish to rename the file, (either the .pdf or .html, I'm not sure), according to the content of its own internal title tag. If that is the case there is very little in what you've got so far which is really of any use to you. There are too many unknowns, and potential pitfalls with the file naming conventions and html contents for it to be worth formulating anything other than a one off solution with very specific criteria. Take your .html file for instance, how can you be assured that the content is formatted in such a way as the title is on its own line and as I've mentioned previously does not contain an attribute? Are you aware that the cmd language is extremely poor at handling common .html characters such as >,&,% and <? Although I'd have once enjoyed the challenge of using command scripts alone to perform this task it simply isn't practical to do so. I would certainly suggest at least integrating the use of third party utilities such a AWK or SED and strongly suggest you contemplate using a programming language more suited to the task. -
renaming files in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Are you simply requiring console output for which .pdf's have associated .html's, or is your intention something else? -
I had already told you to do that too! Thanks for posting back and for providing closure to the problem, it means that other readers with the same or similar problem can use the advice given in the knowledge that it is known to work!
-
for in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
From: SET /? -
renaming files in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
On your original question, could you state whether the .pdf file names always start with a single number or whether they can be two or more numbers together, (3_1_en_pdf, 14_2_en.pdf, 687_3_en.pdf). Could you please also provide the information about .html files you're using, i.e their naming convention. -
for in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Those files don't follow your original specification! This may suffice for that scenario: @ECHO OFF SETLOCAL ENABLEEXTENSIONS FOR /F "TOKENS=*" %%# IN ('DIR/B/S/A-D "gen_*.pdf"') DO CALL :RN "%%#" "%%~nx#" GOTO :EOF :RN SET "_FN=%~2" REN %1 "%_FN:~4%" -
How to run perl command in the DOS box
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Just make sure that you are searching for a title tag <Title>Required Title Text</TITLE> or a title with attribute tag<title="My Title">Required Title Text</TITLE> -
How to move files to directories
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Topic Closed! -
How to move files to directories
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Another solution - (no setting of variables or delayed expansion) @ECHO OFF & SETLOCAL ENABLEEXTENSIONS FOR %%# IN (*.PDF) DO (FOR /F "DELIMS=_- " %%$ IN ("%%#") DO ( IF NOT EXIST "%%$\" MD "%%$" IF EXIST "%%$\" MOVE "%%~nx#" "%%$")) PAUSE -
for in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I'd suggest that you also remove the PAUSE now that you're happy with the result. -
for in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I think I'd be a little more specific with the for/call output: @ECHO OFF SETLOCAL ENABLEEXTENSIONS FOR /F "TOKENS=*" %%# IN ('DIR/B/S/A-D "_K_ENR_*.pdf"') DO CALL :RN "%%#" "%%~nx#" PAUSE GOTO :EOF :RN SET "_FN=%~2" ECHO=REN %1 "%_FN:~7%" -
for in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
'The command before' is simply bad. You don't have to remember it, it's written down! All you need to do is change the three lines according to your specification, (lines 3, 5 and 7), which I completed for you for your particular situation. I'm not going to explain the basic questions you've asked, (you can learn the majority of these within the console window itself). Suffice it to say if you are asking these questions, you should certainly not be in a position to suggest that your effort is in some way better than mine. <Edit /> I didn't change the functionality of what you asked, I simply fixed the poor example you gave. You provided the RENAME command you wanted to use, if that was incorrect too then you cannot pass the blame onto me. The output you have provided is EXACTLY what is intended according to your request. If you wish something different, I'd suggest you provide us with your actual file/directory structures and names and an actual example of what you are wishing to change. That way we can create something specific to your situation. -
for in CMD scripts
Yzöwl replied to DosCode's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I'd suggest something more along these lines: @ECHO OFF & SETLOCAL ENABLEEXTENSIONS REM Path to parent directory for recursion (SET _P=WWW.SLV.DK\DOKUMENTER\DSWEB\GET) REM Old filename string to replace (SET _O=BG_AD_3_BG) REM New filename string to add (SET _N=_) IF NOT EXIST "%_P%" GOTO :EOF IF /I NOT "%CD%"=="%_P%" (PUSHD %_P% && SET "_=T") FOR /D /R %%# IN (*) DO REN "%%#\%_O%*.PDF" "%_N%*.pdf" IF %_%==T POPD PAUSE -
There is a Forum section for humour, and this isn't it. Additionally, once you create a Topic the Forum team decides upon how to deal with it not the Topic starter.
-
I gave you the entries for GuiRunOnce as requested but you decided to go it alone, so you have your wish!