I can't find anything on this error I am getting when renaming some files. I'm pulling info from a csv file and parsing it to build new file names.<br><br>Any pointers appreciated<br><br>Roy<br><br>My code:<br># RENAME FILES using META file - new name = [place]_[state]_[sku].tif<br>
<br>import re, os, csv<br><br># DEFINE<br>_meta_file = "C:\\Documents and Settings\\rhinkelman\\My Documents\\My Dropbox\\Public\\Python code examples\\topo_meta_TEST.csv"<br>_files_to_mod = "\\\\Dc2\\inetpub2\\Image Production\\missing_topo\\topo sz3\\test"<br>
_del_space = re.compile( ' ' )<br><br>#OPEN file containing TOPO meta, DEFINE OLD AND NEW NAMES<br>_meta = csv.reader(open(_meta_file, "r"))<br>for _row in _meta:<br> if _row[0] == "NAME":<br>
continue<br> print '|'.join(_row) # test<br> old_name = _row[4].lstrip('o') + ".pdf"<br> new_name = _row[0] + "_" + _row[1] + "_" + _row[4] + ".pdf"<br>
new_name = _del_space.sub( '_', new_name )<br> print old_name + " - " + new_name # test<br><br># OPEN DIR OF FILES TO BE RENAMED AND LOOK FOR NAME, RENAME AND CONTINUE<br> for fname in os.listdir(_files_to_mod):<br>
if fname == old_name:<br> print fname # test<br> os.rename(fname, new_name)<br> break<br> else:<br> continue<br><br><br>AND the error<br>>>> <br>Aberdeen|CA|36.875|-118.250|o36118h3<br>
36118h3.pdf - Aberdeen_CA_o36118h3.pdf<br>36118h3.pdf<br>Traceback (most recent call last):<br> File "C:\Documents and Settings\rhinkelman\My Documents\My Dropbox\Public\Python code examples\Rename_topo_files.py", line 25, in <module><br>
os.rename(fname, new_name)<br>WindowsError: [Error 2] The system cannot find the file specified<br>