rename files using "system" function
조회 수: 3 (최근 30일)
이전 댓글 표시
I want to rename my files using the "rename" command in "system" function like this:
oldname = 'Michael_Jackson-Beat_It.mp3"
newname = 'Michael Jackson - Beat It.mp3"
system(['rename ' oldname ' ' newname]);
I'm producing the "newname"s automatically from the oldnames and doing this in a huge for loop.
But it doesn't work when there's a space in the name strings, I think due to the "rename" command... How can I solve this problem?
thanks,
댓글 수: 0
답변 (2개)
Azzi Abdelmalek
2013년 3월 3일
편집: Azzi Abdelmalek
2013년 3월 3일
oldname = 'Michael_Jackson-Beat_It.mp3'
newname = 'Michael Jackson - Beat It.mp3'
copyfile(oldname,newname)
댓글 수: 1
Walter Roberson
2013년 3월 3일
편집: Walter Roberson
2013년 3월 3일
system(['rename ''' oldname ''' ''' newname '''']);
댓글 수: 2
Jan
2013년 3월 4일
Under Windows I'd prefer the double quotes:
system(['rename "' oldname '" "' newname '"']);
Walter Roberson
2013년 3월 4일
Under non-Windows systems, if the file names contained dollar-signs, the dollar-signs would trigger substitution (or other effects) inside of double-quotes but not inside of single-quotes. For example,
copy "foo.bar" "foo-$PWD"
would trigger PWD to be expanded rather than being treated as a literal string.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!