TIP: Bulk Rename Files Using Power Shell

I recently wrote about some discounted Python courses in Udemy. In it is a highly recommended course that many beginners who want to learn Python will benefit from -- the Complete Python Bootcamp: Go From Zero to Hero. A factor which I consider makes the most impact in this course is the availability of Python code, where the user could build upon. The course author shared these in the form of jupyter notebooks.

Not only will the student be able to learn Python, but have them in an easy to share or collaborate development environment (jupyter notebooks). I volunteered to download it for a friend and what easy way to do it than the Firefox plugin, Download Them All (DTA).

DTA has this thing called fast filtering. And it will download pretty much all of the notebooks needed for the course without having to click them one by one.

Download Them All Fast Filter

The thing is, when DTA downloaded the files, the extension was changed from the original .ipynb to .html. DTA appended a .html extension to the downloaded file. The question is: Is there a way to do bulk renames of these files so I don't have to do it one by one as well?

Download Them All Renamed Files

It turns out the answer to the question above is built into the Windows Operating System -- Power Shell. So launch Power Shell, the change directory to the location of the downloaded notebook files. And execute: dir *.html | rename-item -NewName {$_.name -replace {".html",""}

Bulk Rename Using Power Shell

The above command will remove the string ".html" from the filenames of all files in the present working folder. In effect, renaming all the files to the original names from the course author's website. Now I could copy the files for my friend, and at the same time keep a copy for myself for future use.

RELATED: Huge Discounts on Python Courses at Udemy

This solution is not limited to the above scenario only. It could be applied to several others and that is happened to be a perfect example. If you have a another solution, or a better solution, please share it in the comments section below.

TIP: Huge Discounts on Python Courses at Udemy

One of the many tools I use for automating my everyday tasks as a sysad is Python.. Be it for executing backups, routine checks, collecting and rotating logs from legacy devices or automation as a hobby, Python has in one way or another been deployed. Now that I shifted careers to a data science, Python is still the language of choice for ETL, data mining, data cleansing and blending, and, even the convoluted advanced machine learning and deep learning coding.

I once shied away from Python due to the inconsistencies between version 2 and version 3. What works on v2, might break on v3 but like I got the hang of it, you will too -- to the point of having both versions available on a virtualenv (virtual environment). Python has helped me a lot not only in job functions as well as my hobbies. To name one, you may automate the download of your favorite TV series episodes using a Python-based software called "Sickrage". I wrote about how to set this up on a Raspberry Pi in this article. Not only that, it takes care of renaming the files according to episode titles and tracks the episodes I have already viewed. Take it for a spin.

It goes without saying that Python has gone a long way in helping me in my professional career and everyday life. The sad thing is that Python coding is not taught in school. That does not mean you will not be able to find a course that could help out in learning how to code in Python.

The course that has helped me out is "Complete Python Bootcamp: Go from zero to hero in Python". This course is currently on sale for $15 at Udemy, from the usual price of $195. That is a 92% discount!

Complete Python Bootcamp

Should you want to take advantage of this offering, click this link to take you there.

This way, you may learn Python at your own free time at your own pace. If you are looking for a programming language to learn, or looking for another scripting language to learn, this is one of them I would highly recommend.

RELATED: Automated TV Series Downloads Using Raspberry-PI

I hope this tip helps you learn Python. If you have seen another discounted course, share it with us through the comments below. Or if you're interested in other Python course aside from the above mentioned, click this link. Or if you want to help others learn Python, click the share button below.

TIP: Quickly Identify Unknown Devices

Those that have gone through the experience of setting up their own home computer or notebooks, or perhaps, recovering from an unwanted drive failure may have experienced this. After installing the Windows operating system, what comes next? Drivers! Even after going through an extensive checklist of drivers from the manufacturer's website, you get the dreaded "Unknown Device".

Below I have a screenshot of the device manager window. This might not be the exact look of what you will see on your computer, but you get the gist of what I'm talking about.

Unknown PCI Device

What happens next? You try to identify the device and install the proper driver for it -- in other words, trial and error (not error and error, I hope). But this consumes a lot of time.

A good friend of mine suggested that I use the tool he uses in his day-to-day computer setups. He is an overclocker and a known PC enthusiast in the Philippines, who goes by the monicker "xzulu".

The tool he is using is PCI-Z. It is known to work on any version of Windows, even Server editions. Best of all, this tool is FREEWARE. You may download a copy of this tool from the developers website.

In relation to the listed unknown device in the screenshot above, I ran this tool and identified that the "RTS5227 PCI Express Card Reader" on my notebook does not have its driver installed. I now have a clear direction on how to resolve this issue.

PCI-Z Screenshot

After downloading the recommended driver from the manufacturer's website, I installed it for the card reader on my notebook and the problem is resolved. This was a very quick fix.

RELATED: Network Profiler and Analyzer

I hope this tip helps you save time in resolving driver issues for unknown devices on your computer. If you have a better solution, I would love to hear about it. Let me know by leaving a comment.

FAQ: Errors After Deleting SWAP Logical Volume

I was setting up CentOS7 in order to orient myself with SELinux and be comfortable with using it. If you have been an avid follower of my articles, most of the recent ones have been revolving around Ubuntu16 LTS. I really didn't prepare and think much about the requirements for the initial setup and what was required. I simply followed my intuition -- experience has always been reliable and LVM is flexible when it comes to disk requirements.

That flexibility was put into context by this recent setup. Due to missed preparations and mis-calculated assumptions, I had to modify the disk partitioning and took the easiest way out, which is to sacrifice swap. After all, performance would not be very good if a virtual machine started swapping. As it turns out, I dug myself a hole.

At first, the VM took a really long while to boot-up, and eventually error'ed out. The error message started with, "WARNING: Could not boot." Fortunate for me, I was able to take a screenshot to share.

WARNING: Could not boot.

Maybe I was cloning VM templates long enough that I'm entirely new to this kind of scenario. I could simply rebuild the swap logical volume and do away with the problem but "what if" I encounter this again in the future? I knew I have to know how to solve this problem (and share the solution found).

I knew that only swap was missing and Linux will work without it. So I simply pressed [CTRL]+[D] and the VM continued to boot-up. The clue to the solution was in the next message shown -- "Warning: You might want to regenerate your initramfs." So I did proceed my research this route (Assumption: maybe swap was hard-coded in initramfs).

Warning: You might want to regenerate your initramfs

To regenerate the initramfs files run "dracut --force --regenerate-all" (NOTE: You might want to take a copy of the files contained in /boot prior to executing this command). After reboot, same thing.

Most of the Google searches returned topics related to Cobbler and Kickstart.. but some of them mentioned checking /etc/grub.conf. However, grub.conf is no longer in /etc but is in /boot/grub2 and under a different name "grub.cfg". So I checked that file, and swap is in fact hard-coded in grub.cfg. And once removed, will resolve the error.

But modifying grub.cfg is dangerous. It can however, be generated using the command grub2-mkconfig and the template files are found in /etc/grub.d and the file /etc/default/grub. Modifications can be done in /etc/default/grub, then re-generate the grub configuration file and dracut command above can do the rest. The commands are shown on the screenshot of the console below.

dracut --force --regenerate-all

After these modifications the virtual machine booted, and was quick to the login prompt, if I may add. Now, I have a sandbox VM in my laptop that I could do experiments with.

RELATED: FAQ: Cloned Linux Virtual Machine with Boot Errors

If it so happens that you deleted the swap logical volume and found yourself in the same exact scenario I was in, this is one solution. If you have any other solution(s), please share. I'm interested to learn other ways to do this.

HOW-TO: Boot to Recovery/Rescue Mode

Booting to Recovery mode or Rescue mode is important. This is primarily due to the single most important reason -- nobody can predict an impending disaster. And this is why infrastructure personnel like me have jobs.

Below I have a screenshot of one of the many reasons that you might want to boot in Recovery mode. The error being "VFS: Unable to mount rootfs on unknown-block(0,0)". The cause for this error is another topic altogether, but this error needs the intervention of a system administrator.

VFS: Unable to mount rootfs

The error can manifest on a baremetal set-up or a virtual machine. The screenshot is on an Ubuntu LTS 16.04 guest running on VMware ESXi v5.5. The guest operating system simply won't boot no matter what.

First restart and interrupt the boot process and modify some boot options. Look for the line containing "linux" and at the end of the line, append "systemd.unit=recovery.target" (NOTE: Both rescue.target and recovery.target works). Then press F10 to boot.

systemd.unit=recovery.target

Modifications above will interrupt the boot process to allow recovery mode of other installed kernel images, otherwise not shown on the boot menu. When presented with that menu, select a recent kernel image a few versions down from the current unbootable one. Make sure to select the option with "(recovery mode)" in it. Otherwise, just input the root password when on the recovery console when prompted.

On the console terminal, remove the unbootable kernel image (or force a reinstall), or execute other applicable steps/procedures to successfully boot the system. Hope this tip helps in accessing the recovery mode or rescue mode the next time a need for it arises.

RELATED: Quantifiably Measure Boot Time Optimizations

Do you have another way to access the recovery mode? Please share it on the comments below.