# How to make a list of files not using Mp3tag - and add a datestamp to it?

**URL:** <https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100>\
**Category:** Off-Topic\
**Created:** [November 20, 2019, 2:34pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100 "2019-11-20T14:34:31Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [November 20, 2019, 2:34pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/1 "2019-11-20T14:34:31Z")

</div>

I need to make a list of all of the files for ma folder that has many sub-folders- in which there are many files  
` `  
` `  
With a BAT like this

`tree P:\YouTube /f > "C:\Archive\File List.txt"`

I get a `File List.txt` in folder `Archive` on drive `C`. It is the minimum I need  
` `  
` `  
The problem with this method are:

A] The TXT file gets overwritten every time I execute the BAT. I can work around that problem with a backup software, but I would prefer to have multiple TXT files in that folder, each with a date and [also maybe time] in its name when the list was created. So for example I would have something like `File List 2019-11-01 12_00_00.txt`, `File List 2019-11-15 16_05_00.txt`, ``File List 2020 01 17 23\_00\_06.txt` etc.

B] The TXT files have a nice graphical form of a tree. But diacritic signs are all massed up. And adding parameter `/a` [using ASCII instead of extended characters, whatever those extended ones are] does not fix that, but [if I am not mistaken] only changes the signs used for the drawing of the tree  
` `  
` `  
So does anyone know what else I can use? To add the date and time to the TXT file and see in it all of the characters

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [November 20, 2019, 5:42pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/2 "2019-11-20T17:42:20Z")

</div>

see this external site:

> <https://serverfault.com/questions/16706/current-date-in-the-file-name>

---

<div class="post-metadata">

**Author:** ![Spider099](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Spider099](https://community.mp3tag.de/u/Spider099)\
**Post date:** [November 20, 2019, 7:46pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/3 "2019-11-20T19:46:38Z")

</div>

Have a look at powershell as you are using Windows

Open a powershell window and navigate to your P:\YouTube directory  
then run

Get-ChildItem -Recurse | Write-Output | Tee-Object -FilePath $("P:\YouTube\File List - "+[datetime]::Now.ToString("yyyy-MM-dd-HH-mm-ss")+".txt") | Out-Null

The above is all one line

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [November 25, 2019, 3:00pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/4 "2019-11-25T15:00:36Z")

</div>

> [@ohrenkino](#):
>
> see this external site:  
> [windows - Current date in the file name - Server Fault](https://serverfault.com/questions/16706/current-date-in-the-file-name)

They seem to get this done there, although it seems to be complicated

And because there is still the problem of diacritic sings, for now I will leave it alone

> [@Spider099](#):
>
> Have a look at powershell as you are using Windows  
> [...]  
> Get-ChildItem -Recurse | Write-Output | Tee-Object -FilePath $("P:\YouTube\File List - "+[datetime]::Now.ToString("yyyy-MM-dd-HH-mm-ss")+".txt") | Out-Null  
> [...]

Nice, as the sub-folders are visually separated on the list and all the diacritic signs are present. But I also get all that excess of information in front of each `Name`, i.e. `Mode`, `LastWriteTime`, `Length`. And I would not know how to remove all of that info If I had to actually use that list. [I tried pasting it into spreadsheet in Excell but could not get them into separate columns]  
` `  
` `  
So I tried coming up with a different code

`Get-ChildItem -Recurse -Include *.* -Name | Write-Output | Tee-Object -FilePath $("P:\YouTube\File List "+[datetime]::Now.ToString("yyyy-MM-dd hh_MM_ss")+".txt") | Out-Null`

With it I get a list, but this time it that has no visual separation between folders, which is a drawback. It has folders and sub-folders in front of `Name`s, so I know I will be able to make a usage of such list- but it still would require then a lot of hand work from me if I actually had to use it. [The purpose of this list to be able to know what I want to watch again in the future in case if all of my backup copies will be inaccessible and my YouTube account will also be of no use or inaccessible]  
` `  
` `  
And if I use a code like that

`Get-ChildItem -Recurse -Include *.* | Format-Table name -hidetableheaders | Write-Output | Tee-Object -FilePath $("P:\YouTube\File List "+[datetime]::Now.ToString("yyyy-MM-dd hh_MM_ss")+".txt") | Out-Null`

then the during the generation of the list it removes the directories thus turning the full-paths into just filenames and also not showing any of the excess information [`Mode`, `LastWriteTime`, `Length`]. Having just `Name`s in a single line is exactly what I am after, but not having block of lines [i.e. content of directories] somehow separated and described with names of directories simply makes such list almost completely useless [as I do not know which video comes from which youtube channel]  
` `  
` `  
So what I need is something that has a space structure like in the code presented by @Spider099 pider099 but limited in information to just the directories / sub-folders paths and the name filenames within each of them; some kind of combination of the first and the third code

Can it be done within PowerShell?

---

<div class="post-metadata">

**Author:** ![Spider099](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Spider099](https://community.mp3tag.de/u/Spider099)\
**Post date:** [November 25, 2019, 7:00pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/5 "2019-11-25T19:00:56Z")

</div>

Yes it can  
Try this - gives "path" then file Name

Get-ChildItem -Recurse -Include _._ | Format-Table directory, name -hidetableheaders | Write-Output | Tee-Object -FilePath $("m:\Music\File List "+[datetime]::Now.ToString("yyyy-MM-dd hh\_MM\_ss")+".txt") | Out-Null

if thats not what you want

Then show an example!

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [February 12, 2020, 6:19pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/6 "2020-02-12T18:19:50Z")

</div>

So let us start from the beginning

[The location of the file to be produced is now **S:\Data**]  
` `  
` `  
**APPROACH-A**

The BAT version  
`tree P:\YouTube /f /a> "S:\Data\File List.txt"`  
produces a list like this:

```
|
+---Channel A
| Some file 1.mp4
| Some file 2.mp4
| Some file 3.mp4
|      
+---Youtuber X
| | Some file 1.mp4
| |  
| \---Videos for editing
| | Some file 1.mp4
| | Some file 2.mp4
| |
| \---Material edited already
| Some file 1.mp4
|
+---Youtuber YY
| Some file 1.mp4
|
+---Youtuber ZZZ
| Some file 1.mp4
| Some file 2.mp4
|

```

It has pretty much a perfect form

The problem with this solution is that diacritic signs are messed up on such list; and that the TXT file does not have a date and time inserted to the end of its name  
` `  
` `  
**APPROACH-B**

My first power shell commands

`Get-ChildItem -Recurse -Include *.* -Name | Write-Output | Tee-Object -FilePath $("S:\Data\File List "+[datetime]::Now.ToString("yyyy-MM-dd hh_MM_ss")+".txt") | Out-Null`

produces a list like this:

```
Channel A\Some file 1.mp4
Channel A\Some file 2.mp4
Channel A\Some file 3.mp4
Youtuber X\Some file 1.mp4
Youtuber X\Videos for editing\Some file 1.mp4
Youtuber X\Videos for editing\Some file 2.mp4
Youtuber X\Videos for editing\Material edited already\Some file 1.mp4
Youtuber YY\Some file 1.mp4
Youtuber ZZZ\Some file 1.mp4
Youtuber ZZZ\Some file 2.mp4

```

It is usable but in order for me to have a pure list of filenames, I would have to delete all that is before every `\` sign; but paradoxically at the same time I would have to preserve name of folders in order to know where they came from  
` `  
` `  
**APPROACH-C**

My second power shell commands

''Get-ChildItem -Recurse -Include _._ | Format-Table name -hidetableheaders | Write-Output | Tee-Object -FilePath $("S:\Data\File List "+[datetime]::Now.ToString("yyyy-MM-dd hh\_MM\_ss")+".txt") | Out-Null''

produces a list like this:

```
Some file 1.mp4
Some file 2.mp4
some file 3.mp4
Some file 1.mp4
Some file 1.mp4
Some file 2.mp4
Some file 1.mp4
Some file 1.mp4
Some file 1.mp4
Some file 2.mp4

```

Which is completely useless. The only advantage of it is that the TXT has the date and time at its end [just like in case of APPROACH-B and APPROACH-D]  
` `  
` `  
**APPROACH-D**  
The new power shell commands

`Get-ChildItem -Recurse -Include *.* | Format-Table directory, name -hidetableheaders | Write-Output | Tee-Object -FilePath $("S:\Data\File List "+[datetime]::Now.ToString("yyyy-MM-dd hh_MM_ss")+".txt") | Out-Null`

made from the latest suggestion of @Spider099 produces a list like this:

```
Channel A Some file 1.mp4
Channel A Some file 2.mp4
Channel A Some file 3.mp4
Youtuber X Some file 1.mp4
Youtuber X\Videos for editing Some file 1.mp4
Youtuber X\Videos for editing Some file 2.mp4
Youtuber X\Videos for editing\Material edited already Some file 1.mp4
Youtuber YY Some file 1.mp4
Youtuber ZZZ Some file 1.mp4
Youtuber ZZZ Some file 2.mp4

```

For me this is usable and even has some visual perks which might come in handy depending on what and how I will be doing with this  
` `  
` `  
But the **perfect solution** would be a list looking like in APPROACH-A but with various diacritic and unusual signs being retained properly; and with date and time added to end to end of filename of the TXT file

Would this was to be done with a BAT or a PS1 file - it would have [I suppose] no difference to me. [Although for now I have failed at turning those Power Shell commands into PS1 files, that could be executed from any place on a drive

---

<div class="post-metadata">

**Author:** ![Spider099](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Spider099](https://community.mp3tag.de/u/Spider099)\
**Post date:** [February 12, 2020, 7:46pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/7 "2020-02-12T19:46:15Z")

</div>

add lastwritetime after name and before hide....

so  
Get-ChildItem -Recurse -Include _._ | Format-Table directory, name, lastwritetime -hidetableheaders  
then add the rest of Approach-d

this will add the date and time of the file to the output as the last column  
@Zerow

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 13, 2020, 7:48am UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/8 "2020-02-13T07:48:31Z")

</div>

Perhaps you have to modify the codepage prior to executing the tree command.  
Open a shell and execute the command  
`chcp`  
to find the current codepage. For Western European PCs this should be 850  
But perhaps 855 (kyrillic) or 866 (Russian) are better.  
see e.g. wikipedia on the codepage:

> **[Code page 850](https://en.wikipedia.org/wiki/Code_page_850)**
>
> Code page 850 (also known as CP 850, IBM 00850, OEM 850, DOS Latin 1) is a code page used under DOS and Psion’s EPOC16 operating systems in Western Europe. Depending on the country setting and system configuration, code page 850 is the primary code page and default OEM code page in many countries, including various English-speaking locales (e.g. in the United Kingdom, Ireland, and Canada), whilst other English-speaking locales (like the United States) default to use the hardware code pag Code p...

  
Once you have found whether changing the codepage would help, add the changing command to the batch job.

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [February 17, 2020, 1:17pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/9 "2020-02-17T13:17:38Z")

</div>

> [@Spider099](#):
>
> add lastwritetime after name and before hide....  
> [...]  
> this will add the date and time of the file to the output as the last column

You mean that it will insert date and time inside the file? If yes- than something is wrong, as it does not

**APPROACH-D MODIFIED** :  
`Get-ChildItem -Recurse -Include *.* | Format-Table directory, name, LastWriteTime -HideTableHeaders | Write-Output | Tee-Object -FilePath $("S:\Data\File List "+[datetime]::Now.ToString("yyyy-MM-dd hh_MM_ss")+".txt") | Out-Null`  
` `  
` `  
And what I noticed: the date at the of file is correct but the time is wrong; even without that new`LastWriteTime` addition. The time is an hour late. Then the correct hour starts to appear at the end of new files created repeatedly but the later a file is created, then the lower value in seconds it gets. Then the correct hour starts to appear the seconds start to go in the right way and in accordance to the OS clock- but the minutes are stuck at the same one  
` `  
` `  
And also the long filenames are truncated with a `...` indicator. The APPROACH-A [via BAT script] does not seem to create such problem

> [@ohrenkino](#):
>
> Perhaps you have to modify the codepage prior to executing the tree command.  
> Open a shell and execute the command  
> `chcp`  
> [...]

I have `Active code page: 852` which is suppose to be a proper one for me

So I should not be getting "glitches" but proper diacritic signs in my TXT files created with BATs?

---

<div class="post-metadata">

**Author:** ![Spider099](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Spider099](https://community.mp3tag.de/u/Spider099)\
**Post date:** [February 18, 2020, 10:22am UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/10 "2020-02-18T10:22:23Z")

</div>

> [@Spider099](#):
>
> this will add the date and time of the file to the output as the last column

Cant see whats difficult with this - you are adding an extra column  
As for the times being wrong - thats something up with your PC  
But as you do lots of modifications - its probably something you have set somewhere

Anyway - i am bored with this now - you have a few options - which you can modify to try and get what you want - or use Google etc

See ya

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [March 14, 2020, 5:56pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/11 "2020-03-14T17:56:13Z")

</div>

> [@Zerow](#):
>
> [...]  
> the **perfect solution** would be a list looking like in APPROACH-A but with various diacritic and unusual signs being retained properly; and with date and time added to end to end of filename of the TXT file  
> [...]

> [@Zerow](#):
>
> [...]  
> I have `Active code page: 852` which is suppose to be a proper one for me
> 
> So I should not be getting "glitches" but proper diacritic signs in my TXT files created with BATs?

**I have found the overall perfect solution** , going around issues with code page - the **APPROACH-M** , where `M` means mashup  
` `  
` `  
Apparently it is possible to invoke Command Line codes within PowerShell. And so when being in PowerShell window with a simple code like this

`Invoke-Expression "tree K:\YouTube /f" | Out-File "S:\Data\YouTube List.txt"`

I create in the `Data` folder that TXT holding a nice visual tree displaying all of the files from that `YouTube` folder and its subfolders. And the filenames are not truncated in any way plus they display all of the diacritic signs correctly

So problem is solved? Not untirely  
` `  
` `  
Unfortunately there is the issue of running PS1 scripts themselves from files. If I am not mistaken, as a supposed security measure the mouse double left click / the `Open` entry from shell menu by default opens PS1 file in Notepad. And so in order to really run them the `Run with PowerShell` entry from the shell menu must be chosen [instead of `Open`]. That can be of course changed by navigating in the Registry to

`Computer\HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command`

and changing the `Value data` there from

`"C:\Windows\System32\notepad.exe" "%1"`

to

`"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "%1"`

[or alternatively making this permanent association by using the `Open with` option available at the shell menu]

But of course it could not be possibly that simply. Because after changing in the operating system the meaning of `Open` for PowerShell, that PowerShell now stops creating the TXT file at all, informing that

```
C:\Program : The term `C:\Program` is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
A line:1 char:1
+C:\Program Files Expanded/YouTube List.ps1
+ ~~~~~~~~~~
    + CategoryInfo : ObjectNotFound" (C:Porogram:String) [], CommandNotFoundException
    + FullyQualifiedErrorId :</b> **`CommandNotFoundException`

```

[That `C:\Program Files Expanded\YouTube List.ps1` is where the file with the script is residing]

So right now for me it is either [by default] impossible to run PS1 scripts in a convenient way i.e. in form of files from their shortcuts [because double clicking LNK file will open Notepad thus merely show an evoked script]; or [after de-associating PS1 files with Notepad] it is impossible to run PS1 scripts in form of files at all [because PowerShell tries to read the path to them as some kind of a command]

` `  
` `  
So there are probably three workarounds to this:

**WORKAROUND-1]** Do not tamper with how PS1 files are being run [i.e. leave the default behavior] but create a BAT file that will run that particular PS1 file

In theory in CMD this should work

`powershell.exe -command "Invoke-Expression "tree K:\YouTube /f" | Out-File "S:\Data\YouTube List.txt""`

While when such BAT is executed it flashes the error message

```
Invoke-Expression : A positional parameter cannot be found that accepts argument 'K:\YouTube'.
At line:1 char:1
+ Invoke-Expression tree K:\YouTube /f | Out-File S:\Data\YouTube List. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **
    + CategoryInfo : InvalidArgument: (:) [Invoke-Expression], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeExpressionCommand

```

And when the same code is executed directly form the prompt line of the CMD window, a pop up windows appears saying

`This app can't run on your PC`

after closing which it is followed by message

`Access is denied.`

written in the CMD window  
` `  
` `  
**WORKAROUND-2]** After de-associating PowerShell with Notepad, fix it somehow to read the path as path

It is mind staggering why and how changing

`Computer\HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command`

makes the software itself read paths within scripts as commands  
` `  
` `  
**WORKAROUND-3]** Use some third party software that will turn PS1 file into EXE

I am afraid that similar problems will arise, with paths being read as commands. Or there ill be some others issues  
` `  
` `  
As for the time parameter issue

> [@Zerow](#):
>
> [...]  
> insert date and time inside the file?  
> [...]

> [@Zerow](#):
>
> [...]  
> the date at the of file is correct but the time is wrong  
> [...]

I tried changing the `datetime` / `yyyy-MM-dd hh_MM_ss` to `date` / `yyyy-MM-dd` and `time` / `hh_MM_ss` while also tampering with the other portion of the code, but I gave it up this, as I am not a programmer. I can operate with just one TXT being created and then overwritten over and over again [as I make multiple copies of that file with other means]

---

<div class="post-metadata">

**Author:** ![Spider099](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Spider099](https://community.mp3tag.de/u/Spider099)\
**Post date:** [March 15, 2020, 12:42am UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/12 "2020-03-15T00:42:33Z")

</div>

> [@Zerow](#):
>
> powershell.exe -command "Invoke-Expression "tree K:\YouTube /f" | Out-File "S:\Data\YouTube List.txt""

sigh!  
use this example instead for you bat file - so PS can evaluate the command properly  
powershell.exe -command "Invoke-Expression 'tree M:\music /f' | Out-File 'm:\music\test.txt'"

use single quotes and double quotes only around the whole expression after -command  
single and double quotes are evaluated differently in PS

and as you dont understand why PS scripts are not set to execute like bat files do then dont play around with the registry settings as you will get in a mess as you have.

Hence why you were getting errors and unexpected results , besides you commands were wrong

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [March 15, 2020, 4:20pm UTC](https://community.mp3tag.de/t/how-to-make-a-list-of-files-not-using-mp3tag-and-add-a-datestamp-to-it/47100/13 "2020-03-15T16:20:29Z")

</div>

**To sum up**  
` `  
` `  
In command prompt of the PowerShell window this code works

`Invoke-Expression "tree K:\YouTube /f" | Out-File "S:\Data\YouTube List.txt"`

and it can be also saved as a PS1 file  
` `  
` `  
And when reworked to

`powershell.exe -command "Invoke-Expression 'tree K:\YouTube /f' | Out-File 'S:\Data\YouTube List.txt'"`

it can be inserted successively into a BAT file  
` `  
` `  
Both of the above will result in creation of TXT file looking like this

```
K:\YOUTUBE     
├───Channel A
│ Some file 1.mp4
│ Some file 2.mp4
│ Some file 3.mp4
│      
├───Youtuber X
│ │ Some file 1.mp4
│ │  
│ └───Videos for editing
│ │ Some file 1.mp4
│ │ Some file 2.mp4
│ │  
│ └───Material edited already
│ Some file 1.mp4
│              
├───Youtuber YY
│ Some file 1.mp4
│      
├───Youtuber ZZZ
        Some file 1.mp4
        Some file 2.mp4

```

with very long filenames and diacritic signs being retained; and without the need of making any changes to the operating system [at least in case of Windows 10]  
` `  
` `  
Thank you all for the time put into helping me with this task
