Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107920
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Jianling Fan <fanjianling@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: about special characters |
| Date | Sat, 30 Apr 2016 12:13:51 -0600 |
| Lines | 137 |
| Message-ID | <mailman.267.1462040034.32212.python-list@python.org> (permalink) |
| References | <CAJ7mry+o=PRGtM46HPGdNVqaowy3tmheJKu38nRy4y_QEjqV-w@mail.gmail.com> <mailman.234.1461973268.32212.python-list@python.org> <572403de$0$1601$c3e8da3$5496439d@news.astraweb.com> <CAJ7mryKF5N4crnz2Lu36JC=LiqCKYCtwjgoV4U_=h4=ovN6Q6w@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de /zPPbM7FfQ2oy3zJkiSOIA8GyKVDKn22qVlL8FyPFuRw== |
| Return-Path | <fanjianling@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'win32': 0.03; 'sys': 0.05; '__name__': 0.07; 'filename': 0.07; 'filenames': 0.07; 'cc:addr:python-list': 0.09; "%s'": 0.09; 'filename,': 0.09; 'filename.': 0.09; 'skip:" 80': 0.09; 'src': 0.09; 'src,': 0.09; 'subject:characters': 0.09; 'received:209.85.218': 0.10; 'python': 0.10; '2.7': 0.13; 'def': 0.13; 'ignore': 0.14; 'everyone,': 0.15; "'__main__':": 0.16; '2.7.2': 0.16; '2016': 0.16; '236,': 0.16; 'dest': 0.16; 'dest)': 0.16; 'names?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sync': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.16; 'directory.': 0.18; 'version.': 0.18; '>>>': 0.20; 'windows': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '"",': 0.22; 'os,': 0.22; 'problem:': 0.22; 'trying': 0.22; 'cc:no real name:2**0': 0.22; 'am,': 0.23; 'bit': 0.23; 'sat,': 0.23; 'import': 0.24; '(most': 0.24; 'header :In-Reply-To:1': 0.24; 'script': 0.25; 'skip:" 20': 0.26; 'error': 0.27; 'skip:# 10': 0.27; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; 'skip:( 20': 0.28; '"no': 0.29; '50,': 0.29; 'path,': 0.29; 'url:mailman': 0.30; 'code': 0.30; 'skip:[ 10': 0.31; 'post': 0.31; 'another': 0.32; 'good.': 0.32; 'problem': 0.33; 'source': 0.33; 'url:python': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'traceback': 0.33; 'url:listinfo': 0.34; "skip:' 20": 0.34; 'file': 0.34; 'skip:d 20': 0.34; 'received:google.com': 0.35; 'path': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'done.': 0.37; 'list.': 0.37; 'received:209': 0.38; 'delete': 0.38; 'names': 0.38; 'files': 0.38; 'copying': 0.38; 'skip:o 20': 0.38; 'skip:e 20': 0.39; 'url:mail': 0.40; 'some': 0.40; 'your': 0.60; 'above,': 0.63; 'more': 0.63; 'different': 0.63; 'our': 0.64; 'between': 0.65; '20,': 0.66; 'here': 0.66; 'special': 0.73; 'yourself': 0.73; '[error': 0.84; 'again!': 0.84; 'greek': 0.84; 'latin': 0.84; 'shoes.': 0.84; '74,': 0.93; 'imagine': 0.96 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-transfer-encoding; bh=uSHwyr6MUALOTrJeanyCJRM41mHmvS82W5PmFPZ3f68=; b=FEJ2t+8370sea1f36MamXQ1cHmSkIwVadr7tbl2CWNl06+JzrElpPWFO6fWHYjZj5v AfYQfsb7Z7L/lLHUuHLBvIpKXyNpI3N31qycVKSFtcQI4r60M+72xWPo5tvtghiyRz9a M6/V/jl9M4TAvbJ1Pi6nYDbRe6D9hzRJ31XwjGPcFt6TwqoS0pRZduR2ZHZsmWi1wkpM Do8RZ06bmKQQDN57Imrmllid5/PbyCzy/qs3XhsArPENPpAOQ8EfH9DGENg0F54hporS 96yX5cXsYbopPcsa6ysOfyBl0dstbB4L/SF5E3Kg2btB0QiYIP41XHhGoWgM8FpJTBYH GmSQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=uSHwyr6MUALOTrJeanyCJRM41mHmvS82W5PmFPZ3f68=; b=aKdokPTi/X0nuoJZ7ct2mVfwYbJDYdeH/F6cEaEDTy5RzKPxiSNruAY1aa0W+ZiGtU s6lB4w8HtpU9HrsqTP3Y4QGX/NxsSpaWe9TE++AjkRnffmCBG4i+r1u+wt9mAksgpu/Q rcwiH0U0ykDgLezy5diZZzADMziuOpKQ/sGEK1K4e8nsZIRalCVNTaeLxvKaDXkldcHP +C7/URfd1gWMPKPv76pbocf3CHYWxeJZBUXkKdvdU45mgAGskH1sh1DP89vM1/rXdFdX XrQyNds1LvWmdzX4f3lUZGIJTdqMrGh4PcOU60kYvCXhRSN+LjlLmx7/Tjf1fJs6iRo5 jZgw== |
| X-Gm-Message-State | AOPr4FUDBIUslk3Ox3p+4Ayb0y6PgGFVJVTEy31KozuLqZFgLX0M4UpwdM9fIv0MwgCnWmObJIisJXNG/TAXCw== |
| X-Received | by 10.202.184.6 with SMTP id i6mr12268823oif.76.1462040031648; Sat, 30 Apr 2016 11:13:51 -0700 (PDT) |
| In-Reply-To | <572403de$0$1601$c3e8da3$5496439d@news.astraweb.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAJ7mryKF5N4crnz2Lu36JC=LiqCKYCtwjgoV4U_=h4=ovN6Q6w@mail.gmail.com> |
| X-Mailman-Original-References | <CAJ7mry+o=PRGtM46HPGdNVqaowy3tmheJKu38nRy4y_QEjqV-w@mail.gmail.com> <mailman.234.1461973268.32212.python-list@python.org> <572403de$0$1601$c3e8da3$5496439d@news.astraweb.com> |
| Xref | csiph.com comp.lang.python:107920 |
Show key headers only | View raw
Hello everyone,
Thanks very much for all your replies and sorry for the inconvience.
This is my first time to post question in this list.
I am using python 2.7 in Windows 7 Enterprise version.
Here is the the filename that cause the problem: "Decock-2013-On the
potential of δ18O and δ15N.pdf"
When I delete the "δ" in the filename, the script works good.
Here is the output:
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> runfile('P:/sync.py', wdir='P:')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 699, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 74, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "P:/sync.py", line 50, in <module>
sync_files(src, dest)
File "P:/sync.py", line 43, in sync_files
sync(dir_cmp)
File "P:/sync.py", line 20, in sync
shutil.rmtree(f_right)
File "C:\Python27\lib\shutil.py", line 236, in rmtree
onerror(os.listdir, path, sys.exc_info())
File "C:\Python27\lib\shutil.py", line 234, in rmtree
names = os.listdir(path)
WindowsError: [Error 3] The system cannot find the path specified:
'P:/mystuff\\Decock-2013-On the potential of d18O and d15N.pdf/*.*'
Here is my code to do this work: I am using this script to sync my
files between different disks.
#coding=utf-8
import filecmp, shutil, os, sys
SRC = r'C:/Disk/mystuff'
DEST = r'P:/mystuff'
IGNORE = ['Thumbs.db']
def get_cmp_paths(dir_cmp, filenames):
return ((os.path.join(dir_cmp.left, f),
os.path.join(dir_cmp.right, f)) for f in filenames)
def sync(dir_cmp):
for f_left, f_right in get_cmp_paths(dir_cmp, dir_cmp.right_only):
if os.path.isfile(f_right):
os.remove(f_right)
else:
shutil.rmtree(f_right)
print('delete %s' % f_right)
for f_left, f_right in get_cmp_paths(dir_cmp,
dir_cmp.left_only+dir_cmp.diff_files):
if os.path.isfile(f_left):
shutil.copy2(f_left, f_right)
else:
shutil.copytree(f_left, f_right)
print('copy %s' % f_left)
for sub_cmp_dir in dir_cmp.subdirs.values():
sync(sub_cmp_dir)
def sync_files(src, dest, ignore=IGNORE):
if not os.path.exists(src):
print('= =b Please check the source directory was exist')
print('- -b Sync file failure !!!')
return
if os.path.isfile(src):
print('#_# We only support for sync directory but not a single
file,one file please do it by yourself')
print('- -b Sync file failure !!!')
return
if not os.path.exists(dest):
os.makedirs(dest)
dir_cmp = filecmp.dircmp(src, dest, ignore=IGNORE)
sync(dir_cmp)
print('^_^ Sync file finished!')
if __name__ == '__main__':
src, dest = SRC, DEST
if len(sys.argv) == 3:
src, dest = sys.argv[1:3]
sync_files(src, dest)
Thanks again!
On 29 April 2016 at 19:01, Steven D'Aprano <steve@pearwood.info> wrote:
> On Sat, 30 Apr 2016 09:33 am, Jianling Fan wrote:
>
>> Hello everyone,
>>
>> I am trying to use python 27 copying some of my folders and files to
>> another directory.
>> My code works good for other files but I have some problem to copy
>> files that have some special characters in the filename. like
>> filenames contain Greek "δ" or latin "š".
>> it always gave a error that "No such file or directory:"
>>
>> Any help will be appreciate!
>
> Please put yourself in our shoes. Read your message above, and, imagine that
> you know NOTHING else about your program than what you write above. What
> answer would you give?
>
> Please tell us what you have actually done. How do you copy the files? How
> do you enter the file names? What OS are you using?
>
>
>
> --
> Steven
>
> --
> https://mail.python.org/mailman/listinfo/python-list
--
Jianling Fan
樊建凌
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
about special characters Jianling Fan <fanjianling@gmail.com> - 2016-04-29 17:33 -0600
Re: about special characters Steven D'Aprano <steve@pearwood.info> - 2016-04-30 11:01 +1000
Re: about special characters Jianling Fan <fanjianling@gmail.com> - 2016-04-30 12:13 -0600
Re: about special characters Terry Reedy <tjreedy@udel.edu> - 2016-04-30 15:36 -0400
Re: about special characters MRAB <python@mrabarnett.plus.com> - 2016-04-30 20:42 +0100
Re: about special characters Jianling Fan <fanjianling@gmail.com> - 2016-04-30 13:48 -0600
csiph-web