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. 


Sign in to follow this  
DosCode

renaming files in CMD scripts

Recommended Posts

That's because .pdfs starting with a digit only do so because you've already ran a completely unnecessary script on the files to change their name, that's not my fault, its yours.

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.

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.

HI,

would you be able to get text from pdf document using script?

Yes I would!, but if you think for one minute that we are going to start anther four page Topic based on this sparse request, then the answer is most certainly No!

Please don't think that you will get the last word in this Topic unless it is an apology for your failure to listen, learn, understand or adequately thank those who have endeavoured to help you.

Share this post


Link to post
Share on other sites

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.

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.

Edited by DosCode

Share this post


Link to post
Share on other sites

You have once again failed to admit your failures or credit others efforts, this will not help you in further requests for help here. If you cannot see the correlation between give and take then I'm afraid a Forum is not the best place for you to continue your learning process.

Sorry for posting miss-clicking on incorrect button, so I posted the new question in the same thread.
You never, I placed it here because you are not getting another Topic out of that question.

Share this post


Link to post
Share on other sites

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!

Edited by DosCode

Share this post


Link to post
Share on other sites

Your posts generally appear to have one thing in common, negatvity towards the previous respondees help.

PS

Will you please stop editing all of your posts after their content has been read in the context of the thread. I should not have to go back to a post I've already read in order to see if it has changed since I last read it.

The script you have added which was not there before is as bad as the last one you provided and shows that you have not learned anything from the help you've been given here!

Share this post


Link to post
Share on other sites

The script you have added which was not there before is as bad as the last one you provided and shows that you have not learned anything from the help you've been given here!

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!".

Edited by DosCode

Share this post


Link to post
Share on other sites
You never, I placed it here because you are not getting another Topic out of that question.

You could of just left it in the new thread and responded:

"Yes"

The information in your response would have been at the same level of information in the question.

@DosCode, I still would be interested in seeing your COMPLETE solution, since you say you have one, including reading the link you provided, downloading the pages, finding the pdf file names and links, downloading the pdf files if you hadn't already in an earlier step, then moving and renaming the pdf files as you wished and getting rid of any extra stuff downloaded that you no longer needed. I'm always interested in learning new CMD script tricks and I've learned they can come from unlikely sources. So, will you share?

As to your "get text from pdf document using script?" question, you will obviously need to be a lot more descriptive. As I tried to explain earlier, there is absolutely nothing wrong with wanting to learn how to do a task using CMD script if that is what you really want to do. And we are happy to explain how to do specific tasks. But if you will lay out your complete task you are trying to accomplish we can help guide you in how to break up the task into manageable pieces. If you don't want an alternate solution, fine. Just ignore any that are offered, AFTER politely thanking the provider EACH TIME, not just expecting one single "thanks to all posters" to cover things. If you only want conformation that you are on the right track as to the way you have broken the task down, then we will try to refrain from giving you the complete solution at once and only answer the specific questions you ask and only give you examples and not working code so that you can learn on your own, as you seem to want to do. The problem is that when jaclaz tried to do that very thing, you complained that his code didn't work when you clicked on it. And when others offered solutions they were either ignored, brushed off because they weren't using CMD script, or complained to because they didn't give the output you wanted (even though you didn't explain what that was ahead of time).

Most people who come here looking for help want to accomplish a given task. Some want a complete turnkey solution so that they don't have to do the work themselves, and some of those don't care how it works, just that it works. And that is sad. Hopefully they at least say thanks, and most do.

Apparently you are more interested in learning how rather than the speed of getting to the solution, and that is admirable. But if that is the case, you will need to:

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

Then for each step you want to learn how to do, provide the code you have attempted to write and we will try to help you with it.

But if we tell you that you could get from input to output using different steps than what you have chosen, please at least listen to us. We'll try not to suggest (too often) using a different scripting language, but we might know a better path to take to get from A to B.

Anyone who has ever been a true student knows that that if they really want to learn they will have to listen, and yes question what they are told, and do a whole lot more work than the teacher.

I ask you - if you "have many bad habits and in my country we say "You cannot learn an old dog dancing!"." - then why did you come here if not to learn something? I'm afraid that most of us have our own habits including how we want to teach someone how to do something. If our methods and yours don't get along for any reason, then you are encouraged to go elsewhere and find someone who can better meet your needs. We won't try to change you if you don't try and change us.

Cheers and Regards

Edited by bphlpt

Share this post


Link to post
Share on other sites

It is the script which is extremely poor, not the method you've used.

Edited by Yzöwl
In line warning removed

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

<edited code>

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.

No problem :), I have casually saved your previous code (the one that you originally posted tagged as "your final solution") so that is preserved for posterity's sake:

@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"

for /f "delims=" %%b in ('find /i "<title>" ^< "%%H"') do (

set "pdf=%%P"

set "source=%%H"

set "var=%%b"

call :JUMP

)

)

)

)

:JUMP

REM Get title for pdf from html file

set "source=%source%"

set "pdf=%pdf%"

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!" (

REM 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"

)

)

)

jaclaz

Share this post


Link to post
Share on other sites

@DosCode, I still would be interested in seeing your COMPLETE solution, since you say you have one, including reading the link you provided, downloading the pages, finding the pdf file names and links, downloading the pdf files if you hadn't already in an earlier step, then moving and renaming the pdf files as you wished and getting rid of any extra stuff downloaded that you no longer needed. I'm always interested in learning new CMD script tricks and I've learned they can come from unlikely sources. So, will you share?

You can download my files here:

My link

NO WARRANTY!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...