Renaming files

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Renaming files

Houssin, Nathalie Samantha Laetitia
Hello,

I hope everyone is safe and coping with the sanitary situation.
I am trying to rename batch of files and have not been able to come up with a solution not too time consuming
My files are labeled with C00XZ00Y and I would like to put a string in between as well as add the suffix _t00Z
so that it would look like C00X_Z00Y_t00Z
My stacks are comprised of 25 to 40 images with 3 channels
Thank you for any help you can provide with this

Bests,

Nathalie

Here is a link if you want to see the filenames
https://www.dropbox.com/sh/4qc2e1qyq1b4vr8/AAC9kPzGvFXE-8rzN5eD95Epa?dl=0


Nathalie HOUSSIN, PhD
Ohio State University - College of Optometry
Plageman's Lab
Fry Hall room 341c
338 W 10th avenue
Columbus, Ohio 43210
Tel: 614-292-3346

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Renaming files

Yuekan Jiao-2
You may want to try renamer:

 https://www.den4b.com/products/renamer

Yuekan

On Sat, Apr 4, 2020 at 4:08 PM Houssin, Nathalie Samantha Laetitia <
[hidden email]> wrote:

> Hello,
>
> I hope everyone is safe and coping with the sanitary situation.
> I am trying to rename batch of files and have not been able to come up
> with a solution not too time consuming
> My files are labeled with C00XZ00Y and I would like to put a string in
> between as well as add the suffix _t00Z
> so that it would look like C00X_Z00Y_t00Z
> My stacks are comprised of 25 to 40 images with 3 channels
> Thank you for any help you can provide with this
>
> Bests,
>
> Nathalie
>
> Here is a link if you want to see the filenames
> https://www.dropbox.com/sh/4qc2e1qyq1b4vr8/AAC9kPzGvFXE-8rzN5eD95Epa?dl=0
>
>
> Nathalie HOUSSIN, PhD
> Ohio State University - College of Optometry
> Plageman's Lab
> Fry Hall room 341c
> 338 W 10th avenue
> Columbus, Ohio 43210
> Tel: 614-292-3346
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Renaming files

Herbie
In reply to this post by Houssin, Nathalie Samantha Laetitia
Good day Nathalie,

concerning labels of type

//
str = "C00XZ00Y";
//
// the following two lines of ImageJ macro code will do
//
a = split( str, "Z" );
str = a[0] + "_Z" + a[1] + "_t00Z";
//
print( str );
exit();

Please try to understand what happen according to these two line by
studying:
<https://imagej.nih.gov/ij/developer/macro/functions.html>

I didn't have a look at the provided link.

Regards

Herbie

:::::::::::::::::::::::::::::::::::::::::::::::::::::::

Houssin, Nathalie Samantha Laetitia wrote

> Hello,
>
> I hope everyone is safe and coping with the sanitary situation.
> I am trying to rename batch of files and have not been able to come up
> with a solution not too time consuming
> My files are labeled with C00XZ00Y and I would like to put a string in
> between as well as add the suffix _t00Z
> so that it would look like C00X_Z00Y_t00Z
> My stacks are comprised of 25 to 40 images with 3 channels
> Thank you for any help you can provide with this
>
> Bests,
>
> Nathalie
>
> Here is a link if you want to see the filenames
> https://www.dropbox.com/sh/4qc2e1qyq1b4vr8/AAC9kPzGvFXE-8rzN5eD95Epa?dl=0
>
>
> Nathalie HOUSSIN, PhD
> Ohio State University - College of Optometry
> Plageman's Lab
> Fry Hall room 341c
> 338 W 10th avenue
> Columbus, Ohio 43210
> Tel: 614-292-3346
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html





--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Renaming files

G. Esteban Fernandez
Hi Nathalie,

Herbie's solution is great!  Much easier than what I would've done :-)
Just add an extension, like .tif, if your files have one.  I'll add
functionality for all files in a folder and add an extension (change the
.tif if your files have a different extension):

folder = getDirectory("Choose a folder to rename files");
files = getFileList(folder);
for(i = 0; i < files.length; i++){
  nameSplit = split(files[i], "Z");
  newFilename = nameSplit[0] + "_Z" + nameSplit[1] + "_t00Z.tif";
  File.rename(folder + files[i], folder + newFilename);
}

-Esteban

On Sun, Apr 5, 2020 at 4:56 AM Herbie <[hidden email]> wrote:

> Good day Nathalie,
>
> concerning labels of type
>
> //
> str = "C00XZ00Y";
> //
> // the following two lines of ImageJ macro code will do
> //
> a = split( str, "Z" );
> str = a[0] + "_Z" + a[1] + "_t00Z";
> //
> print( str );
> exit();
>
> Please try to understand what happen according to these two line by
> studying:
> <https://imagej.nih.gov/ij/developer/macro/functions.html>
>
> I didn't have a look at the provided link.
>
> Regards
>
> Herbie
>
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::
>
> Houssin, Nathalie Samantha Laetitia wrote
> > Hello,
> >
> > I hope everyone is safe and coping with the sanitary situation.
> > I am trying to rename batch of files and have not been able to come up
> > with a solution not too time consuming
> > My files are labeled with C00XZ00Y and I would like to put a string in
> > between as well as add the suffix _t00Z
> > so that it would look like C00X_Z00Y_t00Z
> > My stacks are comprised of 25 to 40 images with 3 channels
> > Thank you for any help you can provide with this
> >
> > Bests,
> >
> > Nathalie
> >
> > Here is a link if you want to see the filenames
> >
> https://www.dropbox.com/sh/4qc2e1qyq1b4vr8/AAC9kPzGvFXE-8rzN5eD95Epa?dl=0
> >
> >
> > Nathalie HOUSSIN, PhD
> > Ohio State University - College of Optometry
> > Plageman's Lab
> > Fry Hall room 341c
> > 338 W 10th avenue
> > Columbus, Ohio 43210
> > Tel: 614-292-3346
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Renaming files

Bruce Citron
In reply to this post by Houssin, Nathalie Samantha Laetitia
Nathalie-
If you want to rename files separate from ImageJ, a wonderful solution is the app A Better Finder Rename.  It will easily do exactly what you want in one step and you can save the process for future use.  It nicely presents the names that it will look like if you accept the changes.
-Bruce
 


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Renaming files

Jeremy Adler
In reply to this post by G. Esteban Fernandez
Hi Nathalie,
The text Esteban supplied does the heavy lifting - allows you to select a folder, read the names and change them.

There is a simpler version of the renaming part,
based on the name you use - you don't need to "split" and generate an array of pieces

origString="C00XZ00Y";
print("original ",origString);
remove="XZ";// delete.
replacewith="X_Z";// what you want instead.
newSuffix="_t00Z"; // want to add.
newString=replace(origString, remove, replacewith) + newSuffix; ;// replaces every instance of one string with another.
print("new ",newString);

confusingly when I look at the examples from your dropbox, I am unclear how you want to rename these images, the names don't fit the "C00XZ00Y".

Jeremy Adler
BioVis
Uppsala U




-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of G. Esteban Fernandez
Sent: Sunday, April 5, 2020 6:05 PM
To: [hidden email]
Subject: Re: Renaming files

Hi Nathalie,

Herbie's solution is great!  Much easier than what I would've done :-) Just add an extension, like .tif, if your files have one.  I'll add functionality for all files in a folder and add an extension (change the .tif if your files have a different extension):

folder = getDirectory("Choose a folder to rename files"); files = getFileList(folder); for(i = 0; i < files.length; i++){
  nameSplit = split(files[i], "Z");
  newFilename = nameSplit[0] + "_Z" + nameSplit[1] + "_t00Z.tif";
  File.rename(folder + files[i], folder + newFilename); }

-Esteban

On Sun, Apr 5, 2020 at 4:56 AM Herbie <[hidden email]> wrote:

> Good day Nathalie,
>
> concerning labels of type
>
> //
> str = "C00XZ00Y";
> //
> // the following two lines of ImageJ macro code will do // a = split(
> str, "Z" ); str = a[0] + "_Z" + a[1] + "_t00Z"; // print( str );
> exit();
>
> Please try to understand what happen according to these two line by
> studying:
> <https://imagej.nih.gov/ij/developer/macro/functions.html>
>
> I didn't have a look at the provided link.
>
> Regards
>
> Herbie
>
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::
>
> Houssin, Nathalie Samantha Laetitia wrote
> > Hello,
> >
> > I hope everyone is safe and coping with the sanitary situation.
> > I am trying to rename batch of files and have not been able to come
> > up with a solution not too time consuming My files are labeled with
> > C00XZ00Y and I would like to put a string in between as well as add
> > the suffix _t00Z so that it would look like C00X_Z00Y_t00Z My stacks
> > are comprised of 25 to 40 images with 3 channels Thank you for any
> > help you can provide with this
> >
> > Bests,
> >
> > Nathalie
> >
> > Here is a link if you want to see the filenames
> >
> https://www.dropbox.com/sh/4qc2e1qyq1b4vr8/AAC9kPzGvFXE-8rzN5eD95Epa?d
> l=0
> >
> >
> > Nathalie HOUSSIN, PhD
> > Ohio State University - College of Optometry Plageman's Lab Fry Hall
> > room 341c
> > 338 W 10th avenue
> > Columbus, Ohio 43210
> > Tel: 614-292-3346
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html








När du har kontakt med oss på Uppsala universitet med e-post så innebär det att vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du läsa här: http://www.uu.se/om-uu/dataskydd-personuppgifter/

E-mailing Uppsala University means that we will process your personal data. For more information on how this is performed, please read here: http://www.uu.se/en/about-uu/data-protection-policy

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Renaming files

Houssin, Nathalie Samantha Laetitia
In reply to this post by Herbie
Good day Herbie,

I apologize for belated message
Thank you for your help with the macro and your advice on studying the Built-in Macro Functions .. I will have a careful look on the ones that could help me automate some of the tasks I have to do with my batches of images

Bests,

Nathalie

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: Herbie<mailto:[hidden email]>
Sent: Sunday, April 5, 2020 7:55 AM
To: [hidden email]<mailto:[hidden email]>
Subject: Re: Renaming files

Good day Nathalie,

concerning labels of type

//
str = "C00XZ00Y";
//
// the following two lines of ImageJ macro code will do
//
a = split( str, "Z" );
str = a[0] + "_Z" + a[1] + "_t00Z";
//
print( str );
exit();

Please try to understand what happen according to these two line by
studying:
<https://urldefense.com/v3/__https://imagej.nih.gov/ij/developer/macro/functions.html__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgaxoyrlV$ >

I didn't have a look at the provided link.

Regards

Herbie

:::::::::::::::::::::::::::::::::::::::::::::::::::::::

Houssin, Nathalie Samantha Laetitia wrote

> Hello,
>
> I hope everyone is safe and coping with the sanitary situation.
> I am trying to rename batch of files and have not been able to come up
> with a solution not too time consuming
> My files are labeled with C00XZ00Y and I would like to put a string in
> between as well as add the suffix _t00Z
> so that it would look like C00X_Z00Y_t00Z
> My stacks are comprised of 25 to 40 images with 3 channels
> Thank you for any help you can provide with this
>
> Bests,
>
> Nathalie
>
> Here is a link if you want to see the filenames
> https://urldefense.com/v3/__https://www.dropbox.com/sh/4qc2e1qyq1b4vr8/AAC9kPzGvFXE-8rzN5eD95Epa?dl=0__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgZ4-o-7S$<https://urldefense.com/v3/__https:/www.dropbox.com/sh/4qc2e1qyq1b4vr8/AAC9kPzGvFXE-8rzN5eD95Epa?dl=0__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgZ4-o-7S$>
>
>
> Nathalie HOUSSIN, PhD
> Ohio State University - College of Optometry
> Plageman's Lab
> Fry Hall room 341c
> 338 W 10th avenue
> Columbus, Ohio 43210
> Tel: 614-292-3346
>
> --
> ImageJ mailing list: https://urldefense.com/v3/__http://imagej.nih.gov/ij/list.html__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgbG3ZGBB$<https://urldefense.com/v3/__http:/imagej.nih.gov/ij/list.html__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgbG3ZGBB$>





--
Sent from: https://urldefense.com/v3/__http://imagej.1557.x6.nabble.com/__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgeNmorcE$<https://urldefense.com/v3/__http:/imagej.1557.x6.nabble.com/__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgeNmorcE$>

--
ImageJ mailing list: https://urldefense.com/v3/__http://imagej.nih.gov/ij/list.html__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgbG3ZGBB$<https://urldefense.com/v3/__http:/imagej.nih.gov/ij/list.html__;!!KGKeukY!i0Y3SdRYsUQMPPBC4Cy1r0WrFKnSBQJsxXSKjUmlwvhentZVYOcYQIxYgbG3ZGBB$>


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Renaming files

Houssin, Nathalie Samantha Laetitia
In reply to this post by Bruce Citron
Thank you Bruce and Yuekan for your suggestions,

I haven’t tried these apps yet but it looks friendly to use so I will keep that in mind for renaming my files.

Bests,

Nathalie


Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: Bruce Citron<mailto:[hidden email]>
Sent: Sunday, April 5, 2020 12:20 PM
To: [hidden email]<mailto:[hidden email]>
Subject: Re: Renaming files

Nathalie-
If you want to rename files separate from ImageJ, a wonderful solution is the app A Better Finder Rename.  It will easily do exactly what you want in one step and you can save the process for future use.  It nicely presents the names that it will look like if you accept the changes.
-Bruce



--
ImageJ mailing list: https://urldefense.com/v3/__http://imagej.nih.gov/ij/list.html__;!!KGKeukY!gSurnwZvtsMyFTEKINKTdGm39kQV0ZRiwofQxXMHZEVh1IMaXWKCa4myKZ2aVVmY$<https://urldefense.com/v3/__http:/imagej.nih.gov/ij/list.html__;!!KGKeukY!gSurnwZvtsMyFTEKINKTdGm39kQV0ZRiwofQxXMHZEVh1IMaXWKCa4myKZ2aVVmY$>


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html