Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Small MATLAB Request ... Pleeez HELP OUT !!

Status
Not open for further replies.

ahmad_abdulghany

Advanced Member level 4
Joined
Apr 12, 2005
Messages
1,206
Helped
102
Reputation
206
Reaction score
22
Trophy points
1,318
Location
San Jose, California, USA
Activity points
11,769
:idea: Hello all ..
I have two problems and i hope i can find solutions for them please try to help me ..
:arrow: I have some files with the same extensions that have periodic file-names ( for esample they are 115 file with names starting from : 4325001.ext through 4325115.ext .. and the problem now that i dont know how can i deal with file-names with matlab to re-name all these files to 001.ext through 115.ext ... I hope you can get the problem and can help ..

:arrow: the second problem : I want to download all the *.ext contents in web pages with periodic names ... i.e. assume for esample the addresses of these pages are like the following :
'http://www.aaa.com/bbb.php/?lw_s=text_b=chapters_id=123001
'http://www.aaa.com/bbb.php/?lw_s=text_b=chapters_id=123002
'http://www.aaa.com/bbb.php/?lw_s=text_b=chapters_id=123003
-------
'http://www.aaa.com/bbb.php/?lw_s=text_b=chapters_id=123234

each page of these pages contain one or more *.ext with non-periodic names at all .. i want to download them making use of Matlab and/or any other download program, but i want this to be in intelligent way not to open the 234 pages one by one and download files in each, this will be very difficult ..

Pleasee notice that i don't understand what is it ment by such internet addres .i.e. i dont know what is the need of '=' , '?' , or '/' and so on .. if you can discuss breifely i will be very happy ..

I hope you can help me to solve such problems as soon as possible ..

Thank you very much :D..
 

Lets see...
this isnt really complicated...we can do it in a simple m file

lets say u have 115 files...

for I=1:115
copyfile(['abc' num2str(I) '.ext'],[num2str(I) '.ext'])
end

hope this solves your first problem

the other one is quite out of my scope

Best of luck
 
If you are using Windows, maybe you could use the handy GrabURL command-line utility. You can then create a batch file and run it. Example:
Code:
graburl [url]https://www.aaa.com/bbb.php/?lw_s=text_b=chapters_id=123001[/url] > 001.ext
graburl [url]https://www.aaa.com/bbb.php/?lw_s=text_b=chapters_id=123002[/url] > 002.ext
graburl [url]https://www.aaa.com/bbb.php/?lw_s=text_b=chapters_id=123003[/url] > 003.ext
I suppose you could even use MATLAB to create and run the batch file.

I'll attach GrabURL 1.05 here because the author's web site is down.
 

thedesolatesoul said:
Lets see...
this isnt really complicated...we can do it in a simple m file

lets say u have 115 files...

for I=1:115
copyfile(['abc' num2str(I) '.ext'],[num2str(I) '.ext'])
end

hope this solves your first problem

the other one is quite out of my scope

Best of luck

Thank you for your reply .. but i still don't know how can i use this to re-name files !!! i think you misunderstood my first problem .. my problem is to rename each file to the first few characters of its current name ... e.g. abc01.ext becomes 01.ext ...
I hope you can help more ..
thank you very much
 

First few characters???

Code:
for i=1:115
  movefile(['4325' sprintf('%03d',i) '.ext'], [sprintf('%03d',i) '.ext']);
end
4325001.ext becomes 001.ext
4325002.ext becomes 002.ext
etc.

Your question isn't totally clear. I assume you know the first few characters of the filenames, and you know how many files there are. Otherwise you'll need to do something like files=ls; or files=ls('4325*'); or maybe files=dir; and then parse the resulting array of filenames.
 
echo47 said:
First few characters???

Code:
for i=1:115
  movefile(['4325' sprintf('%03d',i) '.ext'], [sprintf('%03d',i) '.ext']);
end
4325001.ext becomes 001.ext
4325002.ext becomes 002.ext
etc.

Your question isn't totally clear. I assume you know the first few characters of the filenames, and you know how many files there are. Otherwise you'll need to do something like files=ls; or files=ls('4325*'); or maybe files=dir; and then parse the resulting array of filenames.

I am very happy :D ... thank you very very much echo47 for your help ..
it worked profissionally ..
I want to learn more about how to deal with files ( copy, move, rename, change extensions, convert between formats , ... etc. ) can you guide me where to do so ?

BR
 

The best source of info is probably MATLAB's built-in help. That's how I found "movefile" - I searched for "rename", and found "movefile" near the top of the list. If you find a topic that's close to what you want, but not quite right, be sure to try the "See Also" links at the bottom of the help page.
 

Hello echo
I can say that you totally helped me to solve the first problem .. but for the secoond, I still not able to solve it .. can you help to solve ?

Notice that the garbURL program you had attached with your reply can't be downloaded don't know why ...

Also i wanna clearify a simple special case of my second problem ..

If i wanted to download 234 mp3 files from diffrent pages but all starting with the same download link and files have assending periodic naming from 001.mp3 to 234.mp3 , i generated a text file using matlab containing list of download links of these files ( e.g. from 'htttp://www.aa.com/bb/files/001.mp3' through the end )
and this was so easy as you can see to import this list via any download program such as Download Accelerator ...

But the current problem differs in a point that is the download links are the same in the first part but the file name is random names ... such as :
'htttp://www.aa.com/bb/files/file1.mp3'
'htttp://www.aa.com/bb/files/test_file.mp3'
'htttp://www.aa.com/bb/files/lecture.mp3'
'htttp://www.aa.com/bb/files/final.mp3'

and number of file may be large and to download anyone of them i have to open certain page that contains this file download link..

I hope you could get my problem and be able to find a suitable solution ..

Thanks in advanse...
Ahmad
 

It would be nice to be able to download http://www.aa.com/bb/files/*.mp3, but that will never work on the web.

If you go to http://www.aa.com/bb/files/, does it give you a directory listing, or does it give you a web page, or does it say "directory list denied"? If it gives you a directory listing, then you can copy what you see into a text editor, and modify it into a download script. If it gives you a web page that contains links to all the files, then copy the web page source code into a good text editor that can extract all the *.mp3 strings, and then create your download script. If you get "directory denied" messages, then I don't know how to find the names of the files.

Another possibility is to use a web site ripping application to download the whole web site (some web browsers can do that). Hopefully you can control it well enough to avoid downloading too much unwanted stuff.

I can download the GrabURL file ok. However, if you already have an equivalent utility, then don't bother with GrabURL.
 
dbustan said:
just use cells!
for more info email me at dbustan(at)yahoo.com.I had solved this problem.

I mailed you many times, and you didn't respond!
Are you still there?

HOW TO DOWNLOAD FROM A WEB SITE AS DISCUSSED ABOVE USING CELLS?

DO YOU MEAN MATLAB CELLS OR WHAT?

Thanks,
Ahmad,
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top