Powershell Script to search a string within xml file and locate the associated .wav file and purge if older then 1 year RRS feed

  • Question

  • A folder will be presented with one .txt file, multiple .wav files and multiple .xml files. Both the .wav files and .xml files will have matching file names.

    The .txt file will have a list of extensions - example below:




    The objective is to use the .txt file as a search criteria and search the .xml file for the extension. The extension in the .xml file will be represented as below:

    <x:attribute x:key="extension">1234</x:attribute>

    If the extension from the .txt matches the .xml file then the next step is to see if the audio start time is older than 1 year. This is also represented in the .xml file as:

    <x:attribute x:key="audiostarttime">2015-08-17T15:05:10.352+01:00</x:attribute>

    If the audio start time is older then 1 year then there should be a matching filename in a .wav that needs to be deleted. If the audio start time is not older than 1 year the file should be left alone and not purged.

    Finally an output file is needed of what was removed: Time/date  stamp, Extension and filename

    I'm relatively new to powershell and not very sure where to start. Any help will be appreciated.

    Wednesday, August 9, 2017 12:51 PM

All replies