• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script required to change date format

Explorer ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

 

I'm looking for script where as I need to change full length month to short. I will try to depict my situation as simple as possible. Please don't mind at times I'm not so good at articulation, if my requirement is not clear please let me know.

Here we go....

 

January - Jan.

February - Feb.

August - Aug.

September - Sept.

October - Oct.

November - Nov.

December - Dec.

 

But the above months shouldn't be changed in all instances. For example when we have in the following format then we need to change January 31, 2020 - Jan. 31, 2020. But not when month is alone and even if month and year is together, for example January is alone or January 2020.

 

I hope I'm clear and if I'm missing something please let me know.

 

This will save lot of time instead of finding out these date formats manually.

 

Thank you!!

TOPICS
Scripting

Views

442

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 06, 2020 Feb 06, 2020

Hi Sunil,

 

Give the following snippet a shot

var fullName = ["January", "Februrary", "August", "September", "October", "November", "December"]
var shortName = ["Jan.", "Feb.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."]

for(var i = 0; i < fullName.length; i++)
{
	app.findGrepPreferences = NothingEnum.NOTHING;
	app.changeGrepPreferences = NothingEnum.NOTHING;
	app.findGrepPreferences.findWhat = fullName[i] + "( \\d{1,2}, \\d{4})";;
	app.changeGrepPreferences.changeTo = shortName[i] + "$1";

	var a
...

Votes

Translate

Translate
Community Expert ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

Hi Sunil,

 

Give the following snippet a shot

var fullName = ["January", "Februrary", "August", "September", "October", "November", "December"]
var shortName = ["Jan.", "Feb.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."]

for(var i = 0; i < fullName.length; i++)
{
	app.findGrepPreferences = NothingEnum.NOTHING;
	app.changeGrepPreferences = NothingEnum.NOTHING;
	app.findGrepPreferences.findWhat = fullName[i] + "( \\d{1,2}, \\d{4})";;
	app.changeGrepPreferences.changeTo = shortName[i] + "$1";

	var a = app.activeDocument.changeGrep();
}

app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;

 

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

LATEST

Hi Manan, 

what a prompt reply and your script works like a charm. Thanks a lot!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines