LogFAQs > #877152159

LurkerFAQs, Active DB, Database 1 ( 03.09.2017-09.16.2017 ), DB2, DB3, DB4, DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicWould this be easy for a novice to code?
Sahuagin
04/13/17 9:34:33 PM
#14:


can probly do it in one line at windows command prompt (remember that if you put it in a .bat file you have to double all the % signs)

closest I got so far is:

for /f "tokens=1,2 delims= " %a in ('type data.txt') do rename %a %b.jpg

this is assuming a data file that looks like:

asdf.jpg 1
fdsa.jpg 2
somethingelse.jpg 3


tricky thing with this is that it's hard to undo if you get it wrong. well, actually no it isn't, because you can just swap the arguments to rename.

explanation:

for /f loops over things (type for /? to see help)

"tokens=1,2 delims= " says we want the first and second item after splitting with space

not sure how it works exactly, but using %a means that the tokens will be in %a %b %c, etc... using a different letter doesn't work

('type data.txt') allows for to loop over each line in the file. a really useful one is ('dir /ad/b') which lists all directories in a plain format

rest is self explanatory
---
... Copied to Clipboard!
Topic List
Page List: 1