Code covered by the BSD License  

Highlights from
FileSeries - Rename / renumber files, recursive directories

4.5

4.5 | 4 ratings Rate this file 39 Downloads (last 30 days) File Size: 24.33 KB File ID: #12180

FileSeries - Rename / renumber files, recursive directories

by Frederic Moisy

 

05 Sep 2006 (Updated 02 Jun 2010)

Renaming and renumbering for series of files ; generalize the use of wildcards (*) for CD, LS ...

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

This directory contains a set of functions for recursive operations on files and folders (wildcards on subdirectories allowed), including automatic renaming and renumbering of series of files and folders. This may be useful for handling a large number of files:

   cdw - Change directory (like CD), allowing wildcard (*).
   lsw - List directory (like LS), allowing wildcard (*).
   rdir - Recursive list directory.
   rdelete - Delete files recursively.
   rrmdir - Delete directories recursively.
   renamefile - Rename a series of files.
   renumberfile - Re-number the indices of a series of files
   getfilenum - Get the index of a series of files.

Examples:

   CDW mydir*/dir*12 works as CD, but wildcards (*) are allowed

   F = RDIR('set*/DSC*.*') returns all the files matching DSC*.* in all
   the directories matching set*.

   RENAMEFILE('DSC*.JPG','DSC','myphoto') renames the files 'DSC00001.JPG',
   'DSC00002.JPG',... as 'myphoto00001.JPG','myphoto00002.JPG',...

   RENUMBERFILE('DSC*.JPG','DSC') renumbers the *.JPG files as
   'DSC00001.JPG'...'DSC00100.JPG'.

   N = GETFILENUM('*.JPG','DSC') returns the indices of JPG-files.

See the help for each function for more examples.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
07 Oct 2006 Yogesh Mehta

Great. Was useful for me.

30 Apr 2007 Jack Son

I like your work. It helps me to understand more about matlab.

08 May 2010 Eric Diaz

Really Useful! Thanks!

22 Oct 2010 Lynn MacDonald

Got a java error:
Exception in thread "Timer-1" java.lang.OutOfMemoryError: Java heap space
at java.lang.String.toLowerCase(Unknown Source)
at java.io.Win32FileSystem.hashCode(Unknown Source)
at java.io.File.hashCode(Unknown Source)
at java.util.HashMap.put(Unknown Source)
at com.mathworks.mlwidgets.explorer.control.DirectoryListing.list(DirectoryListing.java:163)
at com.mathworks.mlwidgets.explorer.control.DirectoryListing.getList(DirectoryListing.java:97)
at com.mathworks.mlwidgets.explorer.control.DirectoryListing.getDocuments(DirectoryListing.java:73)
at com.mathworks.mlwidgets.explorer.control.DocumentContextImpl.refreshContents(DocumentContextImpl.java:557)
at com.mathworks.mlwidgets.explorer.control.RefreshDaemon$2.run(RefreshDaemon.java:104)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
??? Operation terminated by user during ==> renamefile at 68

22 Nov 2010 Gustaf Kylberg  
22 Nov 2010 Gustaf Kylberg

I have a question. Do I miss something or is spaces not supported in the filenames used when for example renaming files? When using strings with spaces I get the "is not a directory"-error.

Otherwise I like your set of functions.

/Gustaf

22 Jun 2011 Lube F

renamefile.m bug:
The'faster' method returns:
The syntax of the command is incorrect.
And does nothing. Same command works fine if I edit renamefile to use movefile.
R2011a on XP.
cheers.

Please login to add a comment or rating.
Updates
08 Sep 2006

code improved

08 Sep 2006

bugs fixed

02 Sep 2009

Version 1.40: New LSW, CDW. Some functions run much faster (thanks M. Tabarroki!)

02 Jun 2010

New version 1.50. Bugs fixed in rdir and renamefile

Tag Activity for this File
Tag Applied By Date/Time
path Frederic Moisy 22 Oct 2008 08:37:34
directories Frederic Moisy 22 Oct 2008 08:37:34
files Frederic Moisy 22 Oct 2008 08:37:34
directories Bradley Thomas 17 Dec 2008 03:06:09
files Bradley Thomas 17 Dec 2008 03:06:11
path Bradley Thomas 17 Dec 2008 03:06:11
recursive directory rename renumber files Bradley Thomas 17 Dec 2008 03:06:12
directories Pepe Sanchez 14 May 2009 10:03:18
jokers Frederic Moisy 04 Jun 2010 08:08:38
rename Frederic Moisy 04 Jun 2010 08:08:38
recursive Frederic Moisy 04 Jun 2010 08:08:38
subfolder Frederic Moisy 04 Jun 2010 08:08:38
wildcards Frederic Moisy 04 Jun 2010 08:08:38
renumber Frederic Moisy 04 Jun 2010 08:08:38
potw Shari Freedman 04 Jun 2010 09:19:01
rename Jose Ercolino 05 Jun 2010 10:26:20
files Jose Ercolino 05 Jun 2010 10:26:35
renumber Jose Ercolino 05 Jun 2010 10:26:47
subfolder Jose Ercolino 05 Jun 2010 10:26:49
pick of the week Jiro Doke 11 Feb 2011 20:06:38

Contact us at files@mathworks.com