As I’ve been working on a small project for the past few months, mostly related to backend processing – files, databases etc. The small part of the project needed the ability to read and write zip files. I found the jsZip npm package adequate for my requirement. This allows me to quickly read and write zip files.
Read More
Tag: files
Convert a URL to a valid and safe filename in NodeJS
A recent web scraping project necessitated creating hundreds of files to store scraped web page contents. The question was how best to name the files for a particular url.
Read More
Listing files using glob patterns in nodejs
In a previous post we saw how to monitor files changes in nodejs. This was required in a cron job to check which files were changed by the cron process. I also needed to search for files in a particular directory to check which files were newly created by the process. Although this is possible using the file-state-monitor package, I needed the ability to use glob patterns while searching.
Read More
Monitoring file changes using NodeJS
During script runs – that change files – I frequently need to check which files have been modified by the scripts, especially in CRON automated tasks. This allows me to take appropriate actions depending on the file state change.
Read More
Displaying a list of file stats
Usually after completing a long project I find that I’ve created various extraneous files in the project directory; like zip files or maybe a few big graphic files or some huge MySQL dumps. If the directory sizes are small I can manually delete those unwanted files. But if the directory sizes are big or if they are nested deeply, than it can be quite time consuming. Maybe you left a couple of huge MySQL dumps somewhere and forgot to delete them, thus increasing the project file size. And if you are trying to do the cleanup on a online server then it can be even more painful.
Or maybe you are just curious to find how various types of files are taking up your directory space.
Whatever the reason, below is a small php script that displays the distribution of files in a particular directory and its sub-directories by its type. This can be handy if you would like to see which files are taking up space in your project. Although you can easily do such kind of things with a variety of desktop tools, the following code can easily be used online, or integrated into your existing php application.
Read More
Search & replace in files using php
Searching and replacing content in files is a common task all of us do regularly. Most programmers will implement it using Perl a shell script or through a editor. Perl offers itself as an excellent tool for the required purpose; we PHP programmers are not quite so lucky in that matter. Search/replace is easier from a shell prompt or an editor, but what if you have to do the same programatically in php. File_SearchReplace is a pear package that helps you search/replace in files through a nice object oriented interface.
Read More