Monday 28 May 2018

Automate script | Rename a defined list of filename by a defined list of word powershell

All my code:


    #read list filenames + filter#
$listname = Get-ChildItem 'Y:\Users\H\Documents\D\Game Of Throne' -Filter *.bmp

#Read list file txt#
$line = Get-Content 'Y:\Users\H\Documents\D\Game Of Throne\prod\recup.txt'

#account name#
$count_listname= $listname.count

#account line txt#
$count_line = $line.count




#number of max action (inf_list)#
$count= $count_listname, $count_line
$inf_list= ($count | measure -Min).Minimum

#Var file by file of folder#
$list_split= $listname
$list_split | foreach {
$list_split = $_ -split '*'
Write-Host $list_split []
}

#Var line by line of the textfile#
$line_split = $line
$line_split | foreach {
$line_split = $_ -split '*'
Write-Host $line_split []
}
#Select type to delete#
$erase=Read-Host "Enter the type to delete"

#Select number of line#
$nb = Read-Host "Enter the number line to add."

#Line of replace#
$list_input[$nb] = Read-Host "Line(s):"

#Boucle#

$i= 0
while ($i -le $nb-1) {
$list_input[$i]| rename-item -newname { $_.name -replace ( $erase , $list_input[$nb] )}
$i++
}

#output#
echo "File folder" $listname ""
echo "Fichier texte " $line ""
echo "Number of file in folder" $count_listname ""
echo "Number of line in txt" $count_line ""
echo "Number max of actions" $inf_list ""
echo "Line by line" $line_split ""
echo "List one by one" $list_split ""
echo "Type to delete" $erase ""

#echo table($line_split[n] or $line_split[n]#

I have some problems to automate the script (Read-Host) This is working with the $erase but i need it too for the number of table-line and then the lines (without a textfile)


Hamdoun

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...