Matlab FTP download files with certain string in name - string

I am trying to download only certain files from a folder. The folder contains thousands of files named:
z_cams_c_ecmf_20160904000000_prod_fc_sfc_120_duaod550.nc
z_cams_c_ecmf_20160904000000_prod_fc_sfc_120_gtco3.grib
z_cams_c_ecmf_20160904000000_prod_fc_sfc_000_aod550.nc
etc.etc.
I only want those that end in duaod550.nc and aod550.nc
Is there a way to isolate this string from the filename? Unfortunately I cannot use the .nc because there are other files that have this extention and I don't need them.

Looks like what you need to do is use the a wildcard in the ftp command in matlab. From the help
mget(ftpobj,contents) retrieves the file or folder specified by contents from an FTP server into the MATLABĀ® current folder.
contents --
Character vector enclosed in single quotation marks that specifies either a file name or a folder name. Can include a wildcard character (*).
filelist=mget(ftpobj, '*duaod550*')
filelist=mget(ftpobj, '*aod550*')

Related

Is there a Linux terminal command for creating .xlsx files from .bracken files in a loop in a new folder

Is there a loop I can use to create .xlsx files from .bracken files I currently have and channel them into an output folder?
All that I have now is to convert my .bracken files into .xlsx files using this code cat MG-ABCD12345-0.genus.bracken > MG-ABCD12345-0_genus_bracken.xlsx and files are going into my current working directory. I would like the output in a folder called bracken_excel_files which is located within my current working directory. I would prefer to use common commands such as for for the loop for easier understanding.
bracken appears to be generating/sharing the same output format as kraken, which I saw somewhere to be tab-delimited fields.
If that is true, then that is the essence of what CSV files are.
In that case, you don't need to use the "cat" command (CPU and I/O consuming). You simply need to rename the file with a ".csv" suffix (to make the file format explicitly visible for others), then import that into Excel or OpenOffice/LibreOffice Calc. Each of those tools offer different options for interpreting the input when you use the "Import" function to open the files.

Move files to their respective folder in linux based on the date of the folder and the date of the file

I'm fairly new to bash scripting and linux, and I have a folders with just dates such as
2012-11-20
2012-11-21
2012-11-22
2012-11-23
and I have files with the name data_11202012_randomnumbers_csv.
I would like to create a script that can move every single csv file to it's correct folder by matching the date on the file to the folder.
I've been just typing mv file path but i have 100s of files and I'm wondering if theres an easier way.
Any help would be appreciated.
The following should do it for you. I will explain with comments
for file in your_folder/*; do
# 1. Extract the numbers from the file name
dir="${file#data_}" # remove data_ prefix
dir="${dir%%_*}" # remove everything after first _
# 2. Rearrange the numbers into the desired format
dir="${dir:2:4}-${dir:0:2}-${dir:6:2}"
# 3. Move the file into the directory
mv file dir
done
Here you have a very useful bash cheatsheet where you can learn more about it. It illustrates all the variable expansions I've made in my snippet and more.

How to use wget to download files that begins with a known expression and have a certain date after some unknown words?

I'm trying to download all files of a specific date of a ftp directory usin wget.
The pathname of these files begins as follows:
ftp://nrt.cmems-du.eu/Core/WAVE_GLO_WAV_L3_SWH_NRT_OBSERVATIONS_014_001/dataset-wav-alti-l3-swh-rt-global-al/2018/10/global_vavh_l3_rt_al_C****_P****_20181002
The problem is that each file has different numbers on the spaces where I put *.
So, I want to skip this part of the pathname and specify only the begining of the filename and the date. I know that it is exactly four numbers after letter C and four numbers after letter P.
I tried using **** or ???? and it doesn't work.
Anyone can help me?
If there is more text after the date in the file name, you need to add a * after the date, like this (not including the full URL here):
global_vavh_l3_rt_al_C*_P*_20181002*.nc
Note that this relies on server-side directory listing (the FTP LIST command). It may not always work because the LIST command can be blocked on the server side, or the server produces output that wget cannot process. (The output format sadly is not standardized.)

How to find all files by extension?

I create this code that find for me all files that I have in folders, but I need that code to show me a full name of txt files (only txt) that string I insert there.
For example:
I insert "Alex"
and it searching for all txt files that I have, and if it find it will give me a full name of txt file (example: "redme.txt")
What I need to change in my code?
this my code:
the question in the link below may give you the idea
How to get the first file with a .txt extension in a directory with nodejs?
First, try to get all files in a directory. Then, Sort out the .txt extensions. Next, compare the filename to the given string in the argument.

Can I upload files with filenames containing "*" character on web-host?

I got a bunch of image files with "*" character in their filename. Everything is working fine if I include the files in my local web-server.
Is there any reason not to upload them on the web-host.
THat depends on file system used. Different file systems allow different sets of characters for file names.

Resources