Re: Tips for IDL-istic file transfer...? Please help me. [message #70821] |
Tue, 11 May 2010 07:01  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
That indicates that your where() is not finding anything. You should
test the number of indexes found, which is already going into n.
By the way, if you are using stregex just to test if a match is found,
it is cleaner to give it the boolean keyword. That way it already
returns true or false, getting rid of the need to test if the position
is -1:
ind=where(stregex(...,/boolean),n)
|
|
|
|
Re: Tips for IDL-istic file transfer...? Please help me. [message #70842 is a reply to message #70828] |
Mon, 10 May 2010 04:18   |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Mon, 10 May 2010 02:01:09 -0700 (PDT), Harry Kim
<kim4ecohydro@gmail.com> wrote:
> "I want to move the files in these folders into one FOLDER named
> '2000-2008'."
If there is no danger for duplicate filenames, you can do something
like this (test it first!!):
source=file_search('C:\tmp\200?.??.??\','*.*')
ind=where(stregex(source,'C:\\tmp\\200[0-8]') ne -1,n)
source=source[ind]
path='C:\tmp\2000-2008\'
file_mkdir,path
file_move,source,path+file_basename(source)
|
|
|
Re: Tips for IDL-istic file transfer...? Please help me. [message #70844 is a reply to message #70842] |
Mon, 10 May 2010 02:01   |
Harry Kim
Messages: 16 Registered: April 2010
|
Junior Member |
|
|
"I want to move the files in these folders into one FILE named
'2000-2008'."
This sentence indicates that I am getting stupid... (T.T) What I was
trying to write was...
"I want to move the files in these folders into one FOLDER named
'2000-2008'."
Sorry for the confusion. Please let me know if you have any solution.
Thanks.
Harry
On May 10, 5:55 pm, Harry Kim <kim4ecohy...@gmail.com> wrote:
> Hi, all! I need your help. I have about 3200 folders. Each folder has
> 2 or 8 files in there.
>
> I am trying to move files in those folders into one folder.
>
> the folder's names are as follows.
>
> '2000.01.01', '2000.01.02', '2000.01.03'... ,'2008.12.31'.
>
> I want to move the files in these folders into one file named
> '2000-2008'.
>
> After I have been repeating to open one folder, to cut files, and to
> copy them into one folder for 15 minutes manually, I feel very stupid.
> I think there must be some way in IDL, but I cannot figure out what to
> do.
>
> Can someone get me out of this stupidity? Please let me know an IDL-
> istic solution for this problem.
>
> Thanks.
>
> Harry
|
|
|
Re: Tips for IDL-istic file transfer...? Please help me. [message #70908 is a reply to message #70828] |
Wed, 12 May 2010 04:23  |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Tue, 11 May 2010 00:05:53 -0700 (PDT), Harry Kim
<kim4ecohydro@gmail.com> wrote:
> Thank you very much for your suggestion. However I still got stuck.
>
> Everytime I tried this way, I got this error message.
>
> % Attempt to subscript SOURCE with IND is out of range.
> % Execution halted at: MOVEFILE_051110 5 D:\MODIS11\MOD11_Workspace
> \Default\movefile_051110.pro
> % $MAIN$
Mind the double "\\" in the stregex input. Also "200[7]" can just be
written "2007". The square brackets indicate a range (e.g. from 0 to
8). Since you one have one number, you can omit the range:
Pro Movefile_051110
source=file_search('D:\MODIS11\Data\MYD11A1.005\2007.??.??\' ,'*.*')
ind=where(stregex(source,'D:\\MODIS11\\Data\\MYD11A1.005\\20 07')
ne-1,n)
source=source[ind]
path='D:\MODIS11\Data\\MYD11A1.005\2007\'
file_mkdir,path
file_move,source,path+file_basename(source)
end
|
|
|