ren.csv:
file,new
1.txt,2.txt
PowerShell como linha de comando:
powershell ipcsv ren.csv^|%{ren $_.file $_.new}
cmd:
for /F "tokens=1,2 delims=," %a in (ren.csv) do ren %a %b
python (crossplataforma):
python rencsv.py
instale o módulo unicodecsv
:
pip install http://pypi.python.org/packages/source/u/unicodecsv/unicodecsv-0.9.4.tar.gz
rencsv.py:
import os, unicodecsv as csv
with open('ren.csv','rt') as csvList:
renList = csv.reader(csvList, delimiter = ',')
for row in renList:
if os.path.exists(row[0]):
os.renames(row[0],row[1])
php (crossplataforma):
php rencsv.php
rencsv.php:
<?php
$csv=array_map('str_getcsv',file('ren.csv'));
for ($i = 0; $i <= count($csv) - 1; $i++) {
if (file_exists($csv[$i][0])) {rename($csv[$i][0], $csv[$i][1]);}}
?>