我对通过 Windows 制作脚本还很陌生。也许我什至需要剧本以外的东西。我已经在 Linux 中使用 sed 和 csv 文件做了一些类似的事情,但我想制作一个 .bat 脚本文件(或类似的文件),它将接受 c 头文件并删除所有尾随空格。
编辑原因:(我的 Svn 存储库不允许尾随空格,并且在使用 C++ UI 表单时,每次我添加新对象(例如按钮)时,它都会添加带有尾随空格的注释)
编辑: 它发生在如下所示的评论之后
"//
// outputStringsTab
// "
示例片段:
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->tabCollection = (gcnew System::Windows::Forms::TabControl());
this->outputStringsTab = (gcnew System::Windows::Forms::TabPage());
this->justificationComboBox = (gcnew System::Windows::Forms::ComboBox());
this->stringSizeDropBox = (gcnew System::Windows::Forms::ComboBox());
this->stringFontLabel = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->stringSizeLabel = (gcnew System::Windows::Forms::Label());
this->stringBackgroundLabel = (gcnew System::Windows::Forms::Label());
this->fontCheckListBox = (gcnew System::Windows::Forms::CheckedListBox());
this->greenRadio = (gcnew System::Windows::Forms::RadioButton());
this->blueRadio = (gcnew System::Windows::Forms::RadioButton());
this->whiteRadio = (gcnew System::Windows::Forms::RadioButton());
this->blackRadio = (gcnew System::Windows::Forms::RadioButton());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label1 = (gcnew System::Windows::Forms::Label());
this->shapePage = (gcnew System::Windows::Forms::TabPage());
this->circleAngleGroupBox = (gcnew System::Windows::Forms::GroupBox());
this->circleAngleLabel = (gcnew System::Windows::Forms::Label());
this->circleAngleStartTextBox = (gcnew System::Windows::Forms::TextBox());
this->circleAngleEndTextBox = (gcnew System::Windows::Forms::TextBox());
this->circleAngleButton = (gcnew System::Windows::Forms::Button());
this->startAngleLabel = (gcnew System::Windows::Forms::Label());
this->degreesLabel2 = (gcnew System::Windows::Forms::Label());
this->endAngleLabel = (gcnew System::Windows::Forms::Label());
this->degreesLabel1 = (gcnew System::Windows::Forms::Label());
this->lineSuppresionGroupBox = (gcnew System::Windows::Forms::GroupBox());
this->squareLineLabel = (gcnew System::Windows::Forms::Label());
this->noneSuppressRadio = (gcnew System::Windows::Forms::RadioButton());
this->topSuppressRadio = (gcnew System::Windows::Forms::RadioButton());
this->bottomSuppressRadio = (gcnew System::Windows::Forms::RadioButton());
this->leftSuppressRadio = (gcnew System::Windows::Forms::RadioButton());
this->rightSuppressRadio = (gcnew System::Windows::Forms::RadioButton());
this->sizeGroupBox = (gcnew System::Windows::Forms::GroupBox());
this->circleRadioButton = (gcnew System::Windows::Forms::RadioButton());
this->shapesHeightWidthLabel = (gcnew System::Windows::Forms::Label());
this->squareRadioButton = (gcnew System::Windows::Forms::RadioButton());
this->heightTextBox = (gcnew System::Windows::Forms::TextBox());
this->heightLabel = (gcnew System::Windows::Forms::Label());
this->sizeSendButton = (gcnew System::Windows::Forms::Button());
this->widthLabel = (gcnew System::Windows::Forms::Label());
this->widthTextBox = (gcnew System::Windows::Forms::TextBox());
this->gaugeTabPage = (gcnew System::Windows::Forms::TabPage());
this->gaugeValueGroupBox = (gcnew System::Windows::Forms::GroupBox());
this->barValueRadioButton = (gcnew System::Windows::Forms::RadioButton());
this->label5 = (gcnew System::Windows::Forms::Label());
this->meterValueRadioButton = (gcnew System::Windows::Forms::RadioButton());
this->label6 = (gcnew System::Windows::Forms::Label());
this->arcValueRadioButton = (gcnew System::Windows::Forms::RadioButton());
this->gaugeValueTrackBar = (gcnew System::Windows::Forms::TrackBar());
this->trackBarLabel = (gcnew System::Windows::Forms::Label());
this->tabCollection->SuspendLayout();
this->outputStringsTab->SuspendLayout();
this->shapePage->SuspendLayout();
this->circleAngleGroupBox->SuspendLayout();
this->lineSuppresionGroupBox->SuspendLayout();
this->sizeGroupBox->SuspendLayout();
this->gaugeTabPage->SuspendLayout();
this->gaugeValueGroupBox->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->gaugeValueTrackBar))->BeginInit();
this->SuspendLayout();
//
// tabCollection
//
this->tabCollection->Controls->Add(this->outputStringsTab);
this->tabCollection->Controls->Add(this->shapePage);
this->tabCollection->Controls->Add(this->gaugeTabPage);
this->tabCollection->Location = System::Drawing::Point(12, 12);
this->tabCollection->Name = L"tabCollection";
this->tabCollection->SelectedIndex = 0;
this->tabCollection->Size = System::Drawing::Size(827, 396);
this->tabCollection->TabIndex = 0;
//
// outputStringsTab
//
this->outputStringsTab->BackColor = System::Drawing::Color::White;
this->outputStringsTab->Controls->Add(this->justificationComboBox);
this->outputStringsTab->Controls->Add(this->stringSizeDropBox);
this->outputStringsTab->Controls->Add(this->stringFontLabel);
this->outputStringsTab->Controls->Add(this->label7);
this->outputStringsTab->Controls->Add(this->stringSizeLabel);
this->outputStringsTab->Controls->Add(this->stringBackgroundLabel);
this->outputStringsTab->Controls->Add(this->fontCheckListBox);
this->outputStringsTab->Controls->Add(this->greenRadio);
this->outputStringsTab->Controls->Add(this->blueRadio);
this->outputStringsTab->Controls->Add(this->whiteRadio);
this->outputStringsTab->Controls->Add(this->blackRadio);
this->outputStringsTab->Controls->Add(this->label4);
this->outputStringsTab->Controls->Add(this->label3);
this->outputStringsTab->Controls->Add(this->label2);
this->outputStringsTab->Controls->Add(this->label1);
this->outputStringsTab->Location = System::Drawing::Point(4, 22);
this->outputStringsTab->Name = L"outputStringsTab";
this->outputStringsTab->Padding = System::Windows::Forms::Padding(3);
this->outputStringsTab->Size = System::Drawing::Size(819, 370);
this->outputStringsTab->TabIndex = 0;
this->outputStringsTab->Text = L"Output Strings";
//
// justificationComboBox
//
this->justificationComboBox->FormattingEnabled = true;
this->justificationComboBox->Items->AddRange(gcnew cli::array< System::Object^ >(3) { L"Left", L"Middle", L"Right" });
...等等
最佳答案
Windows 批处理脚本不提供图灵完备的编程语言,并且主要用于顾名思义 - 将多个命令批处理在一起(否则您将从命令行执行)。现代 Windows 确实提供了大量超过 MS-DOS 批处理文件的扩展,但它仍然不是一个适合您所要求的工具。
Windows 现在包括 PowerShell作为基本命令行处理器和批处理文件的替代方案;你可能最好使用它,但考虑到你可能正在使用 C 和 C++,那么用你已经熟悉的语言编写你自己的实用程序可能会足够简单?
关于c++ - .bat 脚本删除尾随空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28949317/