d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Advise On A Script To Extract File Names > File Names From Folders In Windows
Add Reply New Topic New Poll
Member
Posts: 32,130
Joined: Oct 29 2005
Gold: 100.00
Jul 26 2017 02:16am
How hard is it to write a script to extract filenames from folders?

This is the case:

I have one folder with a lot of sub-folders (no sub-folders in these). In each of these sub-folders I store foto's (100+) I want to extract the foto names (DCS0001.JPG, DCS0002.JPG, etc.) and save them in a txt file.
Preferably I want to extract them of all sub-folders and list them per sub-folder in a .txt file. Also, I just need the file names, not the whole path name.

I have absolutely no programming background, but I expect this can be done with just a few lines of coding. Extracting it by hand takes hours. Is there somebody that can help me?

This post was edited by Hellskin on Jul 26 2017 02:39am
Member
Posts: 16,621
Joined: Jan 7 2017
Gold: 90.58
Jul 26 2017 03:45am
Member
Posts: 3,197
Joined: May 4 2013
Gold: 1,457.00
Jul 26 2017 05:04am
Code

$ tree
.
├── 1
│ ├── file1.png
│ ├── file2.png
│ ├── file3.png
│ └── file4.png
├── 10
│ ├── 11
│ │ ├── file1.png
│ │ ├── file2.png
│ │ ├── file3.png
│ │ └── file4.png
│ ├── file1.png
│ ├── file2.png
│ ├── file3.png
│ └── file4.png
├── 12
│ ├── 13
│ │ ├── 14
│ │ │ ├── 15
│ │ │ │ ├── 16
│ │ │ │ │ ├── 17
│ │ │ │ │ │ ├── file1.png
│ │ │ │ │ │ ├── file2.png
│ │ │ │ │ │ ├── file3.png
│ │ │ │ │ │ └── file4.png
│ │ │ │ │ ├── file1.png
│ │ │ │ │ ├── file2.png
│ │ │ │ │ ├── file3.png
│ │ │ │ │ └── file4.png
│ │ │ │ ├── file1.png
│ │ │ │ ├── file2.png
│ │ │ │ ├── file3.png
│ │ │ │ └── file4.png
│ │ │ ├── file1.png
│ │ │ ├── file2.png
│ │ │ ├── file3.png
│ │ │ └── file4.png
│ │ ├── file1.png
│ │ ├── file2.png
│ │ ├── file3.png
│ │ └── file4.png
│ ├── file1.png
│ ├── file2.png
│ ├── file3.png
│ └── file4.png
├── 2
│ ├── file1.png
│ ├── file2.png
│ ├── file3.png
│ └── file4.png
├── 3
│ ├── file1.png
│ ├── file2.png
│ ├── file3.png
│ └── file4.png
├── 4
│ ├── 5
│ │ ├── 6
│ │ │ ├── file1.png
│ │ │ ├── file2.png
│ │ │ ├── file3.png
│ │ │ └── file4.png
│ │ ├── file1.png
│ │ ├── file2.png
│ │ ├── file3.png
│ │ └── file4.png
│ ├── file1.png
│ ├── file2.png
│ ├── file3.png
│ └── file4.png
└── 7
├── 8
│ ├── 9
│ │ ├── file1.png
│ │ ├── file2.png
│ │ ├── file3.png
│ │ └── file4.png
│ ├── file1.png
│ ├── file2.png
│ ├── file3.png
│ └── file4.png
├── file1.png
├── file2.png
├── file3.png
└── file4.png

17 directories, 68 files
Member
Posts: 3,028
Joined: Mar 23 2016
Gold: 7,568.50
Jul 26 2017 01:53pm
On windows, open cmd and cd to your main folder then type:

Code
dir /D /s > list.txt


Result is something like this:
Code

Directory of E:\thisisprivatefuckyou\

[.] [Abstract C4ds] [Effect C4ds]
[..] [Bubble C4ds] list.txt
1 File(s) 0 bytes

Directory of E:\thisisprivatefuckyou\Abstract C4ds

[.] Platina 20.tif Platina 33.tif Platina 46.tif
[..] Platina 21.tif Platina 34.tif Platina 47.tif
Platina 1.tif Platina 22.tif Platina 35.tif Platina 48.tif
Platina 10.tif Platina 23.tif Platina 36.tif Platina 49.tif
Platina 11.tif Platina 24.tif Platina 37.tif Platina 5.tif
Platina 12.tif Platina 25.tif Platina 38.tif Platina 50.tif
Platina 13.tif Platina 26.tif Platina 39.tif Platina 6.tif
Platina 14.tif Platina 27.tif Platina 4.tif Platina 7.tif
Platina 15.tif Platina 28.tif Platina 40.tif Platina 8.tif
Platina 16.tif Platina 29.tif Platina 41.tif Platina 9.tif
Platina 17.tif Platina 3.tif Platina 42.tif
Platina 18.tif Platina 30.tif Platina 43.tif
Platina 19.tif Platina 31.tif Platina 44.tif
Platina 2.tif Platina 32.tif Platina 45.tif
50 File(s) 243ÿ182ÿ372 bytes

Directory of E:\thisisprivatefuckyou\Bubble C4ds

[.] Effect 13.tif Effect 19.tif Effect 24.tif Effect 7.tif
[..] Effect 14.tif Effect 2.tif Effect 25.tif Effect 8.tif
Effect 1.tif Effect 15.tif Effect 20.tif Effect 3.tif Effect 9.tif
Effect 10.tif Effect 16.tif Effect 21.tif Effect 4.tif
Effect 11.tif Effect 17.tif Effect 22.tif Effect 5.tif
Effect 12.tif Effect 18.tif Effect 23.tif Effect 6.tif
25 File(s) 116ÿ675ÿ218 bytes

Directory of E:\thisisprivatefuckyou\Effect C4ds

[.] Effect 13.tif Effect 19.tif Effect 24.tif Effect 7.tif
[..] Effect 14.tif Effect 2.tif Effect 25.tif Effect 8.tif
Effect 1.tif Effect 15.tif Effect 20.tif Effect 3.tif Effect 9.tif
Effect 10.tif Effect 16.tif Effect 21.tif Effect 4.tif
Effect 11.tif Effect 17.tif Effect 22.tif Effect 5.tif
Effect 12.tif Effect 18.tif Effect 23.tif Effect 6.tif
25 File(s) 246ÿ927ÿ996 bytes

Total Files Listed:
101 File(s) 606ÿ785ÿ586 bytes
11 Dir(s) 4ÿ700ÿ540ÿ928 bytes free
Member
Posts: 32,130
Joined: Oct 29 2005
Gold: 100.00
Jul 31 2017 03:38pm
Quote (annexusquam @ 26 Jul 2017 21:53)
On windows, open cmd and cd to your main folder then type:

Code
dir /D /s > list.txt


Result is something like this:
Code
Directory of E:\thisisprivatefuckyou\

[.] [Abstract C4ds] [Effect C4ds]
[..] [Bubble C4ds] list.txt
1 File(s) 0 bytes

Directory of E:\thisisprivatefuckyou\Abstract C4ds

[.] Platina 20.tif Platina 33.tif Platina 46.tif
[..] Platina 21.tif Platina 34.tif Platina 47.tif
Platina 1.tif Platina 22.tif Platina 35.tif Platina 48.tif
Platina 10.tif Platina 23.tif Platina 36.tif Platina 49.tif
Platina 11.tif Platina 24.tif Platina 37.tif Platina 5.tif
Platina 12.tif Platina 25.tif Platina 38.tif Platina 50.tif
Platina 13.tif Platina 26.tif Platina 39.tif Platina 6.tif
Platina 14.tif Platina 27.tif Platina 4.tif Platina 7.tif
Platina 15.tif Platina 28.tif Platina 40.tif Platina 8.tif
Platina 16.tif Platina 29.tif Platina 41.tif Platina 9.tif
Platina 17.tif Platina 3.tif Platina 42.tif
Platina 18.tif Platina 30.tif Platina 43.tif
Platina 19.tif Platina 31.tif Platina 44.tif
Platina 2.tif Platina 32.tif Platina 45.tif
50 File(s) 243ÿ182ÿ372 bytes

Directory of E:\thisisprivatefuckyou\Bubble C4ds

[.] Effect 13.tif Effect 19.tif Effect 24.tif Effect 7.tif
[..] Effect 14.tif Effect 2.tif Effect 25.tif Effect 8.tif
Effect 1.tif Effect 15.tif Effect 20.tif Effect 3.tif Effect 9.tif
Effect 10.tif Effect 16.tif Effect 21.tif Effect 4.tif
Effect 11.tif Effect 17.tif Effect 22.tif Effect 5.tif
Effect 12.tif Effect 18.tif Effect 23.tif Effect 6.tif
25 File(s) 116ÿ675ÿ218 bytes

Directory of E:\thisisprivatefuckyou\Effect C4ds

[.] Effect 13.tif Effect 19.tif Effect 24.tif Effect 7.tif
[..] Effect 14.tif Effect 2.tif Effect 25.tif Effect 8.tif
Effect 1.tif Effect 15.tif Effect 20.tif Effect 3.tif Effect 9.tif
Effect 10.tif Effect 16.tif Effect 21.tif Effect 4.tif
Effect 11.tif Effect 17.tif Effect 22.tif Effect 5.tif
Effect 12.tif Effect 18.tif Effect 23.tif Effect 6.tif
25 File(s) 246ÿ927ÿ996 bytes

Total Files Listed:
101 File(s) 606ÿ785ÿ586 bytes
11 Dir(s) 4ÿ700ÿ540ÿ928 bytes free


Bro, thanks!!
Member
Posts: 184
Joined: May 12 2017
Gold: 1,435.00
Aug 19 2017 09:30am
Hm. Lets say your folder pic is in "c:\pictures\pic", and lets say that all of your images are jpg or w/e. If you need a list
of filenames do the following:
1) make pic your current directory:
cd\
c:
cd pictures\pic
2) type:
forfiles /m *.jpg /s > c:\list.txt
You will get a list.txt which contains all of the jpg files from pic dir and subdirs, in a filename per line format.
Member
Posts: 16
Joined: Sep 7 2017
Gold: 0.00
Sep 7 2017 09:22pm
It's very nice to have a good tool to do this for many reasons. I use a program called Karen's Directory printer. here's the home page. https://www.karenware.com/powertools/
Retired Moderator
Posts: 19,460
Joined: Jan 26 2004
Gold: 21,052.00
Trader: Trusted
Sep 22 2017 04:01pm
Quote (Hellskin @ 31 Jul 2017 23:38)
Bro, thanks!!


add the /b to the command line.
dir /D /s /b > list.txt
for a clean list you can load directly in excel if you want too.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll