vendredi 27 septembre 2019

How can I remove characters from a line in a text file without renaming the file?

I want to be able to take a file in a folder and write it to a text file in batch or PowerShell.

The output in the text file should have FileName, NewFileName, DateModified.

The FileName is what the file was named before it was ingested in a program and output.

NewFileName is the name of the file that was output from the program and stored in the output folder.

The powershell script below is what I have used to get the name and date modified of the files to display in a text file.

Get-ChildItem -Path D:\Documents\Projects\Trans-Wrapping\TestOut\NewFiles\Audio\ -Recurse | Select-Object @{n='File'; e={$_.Name + "," + $_.LastWriteTime}} | Out-File "D:\Documents\Projects\Trans-Wrapping\TestOut\NewFiles\Audio\Log.txt"
Get-ChildItem -Path D:\Documents\Projects\Trans-Wrapping\TestOut\NewFiles\Video\ -Recurse | Select-Object @{n='File'; e={$_.Name + "," + $_.LastWriteTime}} | Out-File "D:\Documents\Projects\Trans-Wrapping\TestOut\NewFiles\Video\Log.txt"

However, the output I want is the original file name that was ingested.

FileName before ingested in program Some_Name_file.mxf

NewFileName after ingested random_exactly_37_characters_FileName.mxf_random_exactly_11_characters

The original file does not exist anymore, so I could have just added the path of that and said to write its name. So is there a way I can remove those 37 characters before the file name and the last 11 characters at the end of the filename and write that down on the same text file. I do not want to rename the NewFileName because it would change the date modified parameters.

Can anyone support me in this?




Aucun commentaire:

Enregistrer un commentaire