Selective file renaming in Powershell -


i've got large directory of files, many (but not all) of have been backed in place means of copying them , inserting .backup inbetween filename , extension. using powershell create backup of files have been backed once, time tagged .backup.(date).

i'm still new powershell i'm bit shaky basics. in case snag can't think through how select files there exists identical filename .backup. getting .backup files can do, getting .backup-less counterparts , passing them pipe can't yet. guess i'm curious there being exists operator use in where-object or something.

any ideas?

this should give list of filenames of ones have existing backup:

 $files = gci <directory path> -name   $backups = $files | {$_ -match "\.backup\.[^\.]+$"}   $backedup = $backups | foreach {$_ -replace "backup\."}    $newbackups = $backedup |  {$files -contains $_} 

get names of .backup. files.
remove .backup name.
see if original list of files has name matches what's left.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -