Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6593807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:43:45+00:00 2026-05-25T17:43:45+00:00

I’m looking to write a script that will take a bunch of .js files,

  • 0

I’m looking to write a script that will take a bunch of .js files, compress them, and then replace the old ones with the new ones in that same folder. I’ve tried a few things but I find myself continuously encountering new problems one way or another, so I thought it’d be best to turn to the people who have a better understanding that I do and start fresh.

Can anyone point me in the right direction?

Update:
I am using a set of commands similar to this:

>Get-ChildItem c:\NewFolder\ -recurse |
&java -jar yuicompressor-2.4.6

It does not seem like it wants to allow these sort of output usage though. I’m sure there is a way to make this work, but being fairly new still to PowerShell, I’m not too confident I can figure it out on my own just yet.

Update:
Using the suggested command string below, I can get powershell to give me what seems to be a read out of a newly compressed .js but it won’t replace the existing file with the compressed one or write it to the standard out which i believe to be in the same directory in [filename].min.js format.

Update:
A modified version of the suggested command seems to do the trick!

>Get-ChildItem c:\NewFolder\ -exclude jquery*.js,*min.js -recurse | %{java -jar yuicompressor-2.4.6.jar ($_.fullname) -o ($_.fullname)}

However, when the command runs in PowerShell, oddly enough, I am getting an error message from PowerShell regarding the Java command…

java.exe : At line:4 char:72
+ Get-ChildItem c:\Scripts\ -exclude jquery*.js,*min.js -recurse | %{java <<<< -jar yuicompressor-2.4.6.jar ($.fullname)
-o ($
.fullname)}
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError Usage: java -jar yuicompressor-x.y.z.jar [options] [input file]

Global Options
-h, –help Displays this information
–type Specifies the type of the input file
–charset Read the input file using
–line-break Insert a line break after the specified column number
-v, –verbose Display informational messages and warnings
-o Place the output into . Defaults to stdout.
Multiple files can be processed using the following syntax:
java -jar yuicompressor.jar -o ‘.css$:-min.css’ *.css
java -jar yuicompressor.jar -o ‘.js$:-min.js’ *.js

JavaScript Options nomunge Minify only, do not
obfuscate preserve-semi Preserve all semicolons
disable-optimizations Disable all micro optimizations

If no input file is specified, it defaults to stdin. In this case, the
‘type’ option is required. Otherwise, the ‘type’ option is required
only if the input file extension is neither ‘js’ nor ‘css’.

Any idea what PowerShell is trying to tell me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:43:46+00:00Added an answer on May 25, 2026 at 5:43 pm

    Try doing like this:

    Get-ChildItem c:\NewFolder\ -recurse | %{java -jar yuicompressor-x.y.z.jar $_.fullname}
    

    %{..} is alias for foreach-object. You get a set of files from c:\Newfolder ( and its subdirs) and pass each of these, as objects to the next component in the pipeline. This part being an external component that supports neither pipelining nor the objects, you wrap it in the foreach and also supply the file in the form it can understand – the fullname of the file ( which includes the path).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.