FOR command / batch including DIR

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: FOR command / batch including DIR

#16 Post by drgt » 06 Jan 2017 03:58

Compo wrote:If you are only performing a copy, and one which will happen relatively quickly, why would the order matter? If I was copying the content of a script on here, the end product would look exactly the same if copied it from bottom to top or the opposite.


Some devices like the ASUS OPlay list files in disk order rather than alphabetical order. That makes it hard to find what you are looking for. Using this method, the disk order and the alpha order will match. Unfortunately, you have to copy all files from scratch when you add files...

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: FOR command / batch including DIR

#17 Post by drgt » 06 Jan 2017 04:01

Sounak@9434 wrote:I am just replying based on the command you said earlier 'dir c:\a\b\c /a-d /on /b'


Thank you! Just a little edit if you run this from another directory...

Code: Select all

for /f "delims=" %%a in ('dir c:\a\b\c /a-d /on /b') do (
   copy "c:\a\b\c\%%a" "c:\d\e\f"
)

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: FOR command / batch including DIR

#18 Post by drgt » 06 Jan 2017 04:12

One says the pipe character must be used if file names contain spaces:

for /f "delims=|".....

True?

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: FOR command / batch including DIR

#19 Post by Compo » 06 Jan 2017 04:34

False, (leave it as it was).

…and as I've said, it doesn't matter which order you copy those files, it will not effect the default directory sort order.

Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: FOR command / batch including DIR

#20 Post by Sounak@9434 » 06 Jan 2017 04:38

drgt wrote:One says the pipe character must be used if file names contain spaces:

for /f "delims=|".....

True?

As filename can't contain "|"(pipe) character by default it does not matter if you use | as a delim or just leave "delims="

Sounak

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: FOR command / batch including DIR

#21 Post by drgt » 06 Jan 2017 09:32

Compo wrote:…and as I've said, it doesn't matter which order you copy those files, it will not effect the default directory sort order.


Thanks!

Here is an example of disk order listing:
Image

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: FOR command / batch including DIR

#22 Post by Compo » 06 Jan 2017 09:56

@drgt, I fail to see the relevance.

You've shown a couple of images showing directory structures.
That has no bearing whatsoever on the order that files are copied into your specifically named folder.


If you were intercepting the files during their copy, for an intermediate action, I may understand the need to copy them in an order but not for a direct A to B copy process.

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: FOR command / batch including DIR

#23 Post by drgt » 06 Jan 2017 10:33

I will try again.
Image

Image

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: FOR command / batch including DIR

#24 Post by Compo » 06 Jan 2017 11:14

That is just an output of the DIR command, it has no bearing whatsoever on the directory order of files when copied. There should be no relationship between the viewed directory order and the order at which files were copied to the device..

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: FOR command / batch including DIR

#25 Post by drgt » 06 Jan 2017 11:19

Then why the device displays them in alpha order when copied in alpha order and not so when they are copied in the conventional way?

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: FOR command / batch including DIR

#26 Post by Aacini » 06 Jan 2017 12:08

Compo,

Perhaps you not remember, but in the old MS-DOS command.com days the DIR command did not sorted the files in any order, so they always appear in the same order the files were copied to the disk. If you have any device that does not sort the files by name (like many cheap MP3 players, for example), then the files will be processed in the order they were copied to the disk, so in these cases such an order is important.

Antonio

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: FOR command / batch including DIR

#27 Post by Squashman » 06 Jan 2017 12:25

We have Networked attached storage that does this as well. Irritates the hell out of me on that server.

pieh-ejdsch
Posts: 239
Joined: 04 Mar 2014 11:14
Location: germany

Re: FOR command / batch including DIR

#28 Post by pieh-ejdsch » 06 Jan 2017 12:57

The file system at MFT or FAT is like a table of contents (TOC) in books or an archive file.
If the file stored on the hard disk is recorded on these repositories.
Your files are listed in this list.
When you duplicate your files, this list is read and treated one by one like the table of contents.

Phil

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Re: FOR command / batch including DIR

#29 Post by drgt » 06 Jan 2017 13:19

Thank you all for your contributions!
Happy New Year!

Post Reply