Ready, steady… save!
You don’t need a chart to join in. Here are 2 ways to record your savings:
1. Cross it off
Pop a chart into your first post. Saved an amount? Cross it out! Read more »
£0.01 £0.02 £0.03
2. Write it down
Skip the chart and add updates to your first post. Read more »
“Another +£3 saved today. Go me!”
Use +£ before each new saving so it counts towards your total.
We’d like to remind Forumites to please avoid political debate on the Forum.
This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.
Generate a list of Path Statements for lots of scattered files
Comments
-
Just for anyone reading this thread who doesn't already know:-
- The difference between ">file" and ">>file" is that the former directs output to a file, discarding any previous contents, and the latter appends output to the file.
- The use of "(" and ")" around the FOR command in post # collects all of the output from each of the filenames it processes before placing it all in the output file, discarding any previous content. Without brackets, you would only get the output for the very last file in the list. However, I found that it has the side effect of listing all the DIR commands in the output, which may be undesirable.just a note - some of the file extensions are uppercase and some are lowercase. I would like to preserve the case. Does that make a difference ? - thanks
The pathname includes the actual filename of the file, with case preserved, whilst the matching between the list and the files is case-insensitive.0 -
Cornucopia wrote: »However, I found that it has the side effect of listing all the DIR commands in the output, which may be undesirable.
Ah, sorry, I forgot that bit... the interpreter echos commands by default. You can either set echo off, or you can use the @ prefix on a command to suppress that.
for ... do @dir ...
It's used in the examples at
https://ss64.com/nt/for_f.html
but I forgot the significance at the time.
If you were putting it all in a bat script, you'd probably start with a
@echo off
at the top.
https://ss64.com/nt/echo.html
(I once spent a couple of days writing a scripting survival guide when I was forced to use windows for a while. I was pleasantly surprised that it had come quite a long way since the old days of dos, what with grouping commands, etc, but the syntax is somewhat clunky.)0 -
Yes, freefilesync does have a learning curve. You could be correct, but your proficiency might be different too others people. This is day no 3 and still he is still struggling.Cornucopia wrote: »I think a proficient user of Excel will probably have this task done whilst the person installing software will still be puzzling over which download options to use. I'd certainly expect it to take no more than 5 minutes (if that).
But each to their own.0 -
I already have and use FreeFileSynch, but I can't see how it would help, here. As I understand it, it would still require doing manual lookups to find the files in question. With a large number of files to look up, that would be too labour intensive.
Not really. I was never intending to start working on it until the weekend, I just wanted to get the methodology established before then.This is day no 3 and still he is still struggling.
thanks to all.
So far: FOR /f "delims=" %G in (filelist.txt) DO @DIR /b /s %G >>fpaths.txt is working beautifully
0 -
So far: FOR /f "delims=" %G in (filelist.txt) DO @DIR /b /s %G >>fpaths.txt is working beautifully

I'm still getting good use out of this, but I have discovered that if there is a blank line (i.e. just a carriage return/end of paragraph character) in the middle of in filelist.txt, then the resultant fpaths.txt contains *everything* in the current directory, not just the files listed in filelist.txt.
Is there a way to have it just ignore any blank lines in filelist.txt ?
thanks a lot....0 -
Can probably use an IF in the loop... something along the lines of
for ... @if not [%g] == [] @dir/s ...
See https://ss64.com/nt/if.html0 -
thanks, I'll have a play with that
Also, while I'm here - I have found that if any of the files in the original list FILELIST.TXT are not found, the CLI reports "file not found", but doesn't say *which* file is not found. Is there a way of getting it to say which file the error relates to, so I can go and investigate manually ?
thanks0 -
A simple way...? There are far more elegant ways that will require a bit more batch coding but.........
Change the batch text temporarily from
FOR /f "delims=" %G in (filelist.txt) DO @DIR /b /s %G >>fpaths.txt
to
FOR /f "delims=" %G in (filelist.txt) DO @DIR /b /s %G>fpaths.txt
ought to create a new file every time the redirected output goes to a file and thus (hopefully) the last located file path will be output. The file not located will be the next in your list?
Could be that there is more than one file 'missing' so you may need to repeat if more are not located having deleted the missing ones from your file list?
0 -
Hi , thanks but the job doesn't bomb-out when it hits a 'file not found', it still continues to the end, so removing one of the > s just gives me the path of the final (usually successful) file from filelist.txt, (rather than the full list of all the (successfully found) ones that I get with the >> method) ...0
-
Sorry to jump in - looks like you now know the difference between >> and >. Try a batch file fpaths.bat. With your normal FOR command with 2 differences.
Replace %. With %%. And insert line1 as :-
@echo on
This should identify missing files.0
This discussion has been closed.
Categories
- All Categories
- 356K Banking & Borrowing
- 255K Reduce Debt & Boost Income
- 456.3K Spending & Discounts
- 248.5K Work, Benefits & Business
- 606.4K Mortgages, Homes & Bills
- 179.1K Life & Family
- 264.1K Travel & Transport
- 1.6M Hobbies & Leisure
- 16.2K Discuss & Feedback
- 37.7K Read-Only Boards
