Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Unzip, rename and move a file

$
0
0

need some help.

I have this script to unzip and rename the unzipped file to 21 characters then move it to archive folder daily 

Unzip is wokring but reanme and move doesn't work.

_____________________________________________

$7ZipPath = "C:\Program Files\7-Zip\7z.exe"

$zippw = 'test123'

$zipfile = "c:\myfolder\myfile_special_testmode_final_20150606.txt.zip"

$i = ""

& $7ZipPath e -oC:\myfolder\myfile -y -tzip -p"$zippw" "$zipFile"

#rename unzipped file to 21 charactors

Rename-Item $i.Name -NewName ($i.BaseName.Substring(0,21) +$i.Extension -replace "-","")

# archive unused zipped files

Move-Item $zipfile -destination $filepath\archive -Force


Viewing all articles
Browse latest Browse all 6937

Trending Articles