View Full Version : Listing Specific files in a directory

02-10-2003, 10:13 PM
'Evening all

Im after a way to list files in a folder with filenames that are over 42 Chars long.

They all vary in filename length, but all end with the same extension if it helps.

I'd prefer if the output were generated into a txt file... how would I go about doing this?
Is it actually possible?

I can do it in either Doze or Linux, Pref Linux thou.



02-10-2003, 10:24 PM
dir >> file.txt

Will give a listing and append it to that file.

02-10-2003, 10:58 PM
Hmm.. That's sorta what I was after.

No fear though, I've got it sorted in Linux:
ls ?????????????????????????????????????*.mp3 > ~/mp3s

Thanks for that though, I never new you could do that with dir, so I'll keep that in mind!

Thanks JM :-)

02-10-2003, 11:12 PM
You can do the same with any standard command. Just use ">>" which will create a new text file or append to the bottom of the existing one, or use ">" if you want to create a new one or wipe an existing one.

03-10-2003, 01:32 AM
In Linux this will do the trick:

ls | grep '.\{42,\}' > myfile

42 would be the absolute length including the period and ext so you'd probably have to put in 46.

03-10-2003, 01:53 AM
I was origionally thinking I would have to pipe it to grep, so it would appear there is far more than one way to skin this cat!

Graham L
03-10-2003, 06:26 PM
There are least 42 ways to do it. :D

awk (gawk), perl, etc will do it too.